Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   what is the equivalent const char* in cobol (http://www.go4expert.com/forums/equivalent-const-char-cobol-t17993/)

ronald 15Jun2009 05:12

what is the equivalent const char* in cobol
 
Hi There,

does anyone know the equivalent data type in cobol for const char* var in C?

thanks
R

xpi0t0s 15Jun2009 22:04

Re: what is the equivalent const char* in cobol
 
Which version of Cobol are you using (i.e. what compiler - include full details inc full version number and all that)?

ronald 16Jun2009 03:45

Re: what is the equivalent const char* in cobol
 
Microfocus 3.1 and I'm trying from Cobol to call a C++ dll which has a function with the following paramaters:
char *sSQL
const char *sDatabaseName.

Please note that the calling itself is ok (return no error). however, the error occurs at the end of the cobol program.

the following is the error:
114 attempt to access item beyond bounds of memory (signal 11).

If I tried to call only on char *sSQL (without const char *sDatabaseName) then it works.

any clue?

xpi0t0s 16Jun2009 11:39

Re: what is the equivalent const char* in cobol
 
Going by the variable names they both look like input variables (i.e. input to the DLL function). What does the function do with results?

The two variables will be represented the same way in the Cobol program; you can treat both as just char* and ignore the const. Const is just a contract that means the string won't be modified.

Can you reproduce the problem with a short Cobol program (say 10 lines or so in the PROCEDURE DIVISION)?

SaswatPadhi 16Jun2009 13:36

Re: what is the equivalent const char* in cobol
 
Quote:

Originally Posted by ronald (Post 49669)
Please note that the calling itself is ok (return no error). however, the error occurs at the end of the cobol program.

Hmm..:thinking:

Quote:

Originally Posted by ronald (Post 49669)
the following is the error:
114 attempt to access item beyond bounds of memory (signal 11).

That can't be caused by a missing const. Your program might be trying to access array index(es) beyond its size.
Could you please post your code.

BTW, const char * is nothing special. It's just the same char *. The only thing the const keyword does it, it makes the target func aware that it should not alter the char *.


All times are GMT +5.5. The time now is 05:44.