[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[open-cobol-list] Problem calling a known void function
From: |
vince coen |
Subject: |
[open-cobol-list] Problem calling a known void function |
Date: |
Wed, 27 May 2009 13:13:32 +0100 |
User-agent: |
KMail/1.9.6 |
Hi;
I just did cobc -debug -x test1.cbl
and that worked.
Have not played with mixed lang. calls for additional modules but I will want
to use MySql, Oracle, Postgres linkage if I can find a working SQL
preprocessor similar to Oracle's Pro*Cobol as I prefer to use the EXEC verb
as it keeps to a standard but in the meanwhile am using flat files i.e.,
sequential and indexed in a accounting package (General/Nominal, Sales,
Purchase Ledgers, Incomplete Records [for accountants etc] and Stock Control
etc) that goes back 20-30 years that I am issuing as Open Source in the next
month or two.
Vince
On Tuesday 26 May 2009, you wrote:
> Hi,
>
> Thank you for your answer, it make me check my COBOL arguments.
>
> Here is my version and compile information:
>
> # Generated by OpenCOBOL 1.1.0
> # Built Mar 12 2009 17:05:48
> # Packaged Feb 06 2009 10:30:55 CET
> # Environment
> # TMPDIR : /tmp
> # COBCPY : /appl/src/CP
> # Command : cobc -cx -O2 -std=mf -I /appl/src -Wall -fnotrunc
> -fstatic-call -save-temps -t test_free.lst test_free.opc ^^^^^^^^^^^^^
> ------- Note this argument ------------------------------^^^^^^^^^^^^^
>
> If I omit the "-fstatic-call" then it compiles OK.
> The difference is C calling code - the function is searched only at run
> time.
>
> When I changed "free" to "XXXfree", and compiled with "-fstatic-call",
> I got a loader error:
>
> ./test_free.o: In function `test__free_':
> test_free.c:(.text+0x158): undefined reference to `XXXfree'
> collect2: ld returned 1 exit status
>
> But if I omit it (i.e. dynamic call compilation), I get at RUN time:
>
> pntr=0x09914e08
> 123
> libcob: Cannot find module 'XXXfree'
> Exit 1
>
>
> We need static calling because we are migrating many COBOL programs
> (over 1000) with many subroutines (COBOL, FORTRAN and C) and we can't
> wait for the run time to know which subroutines are missing.
>
> So, I'll ask a more precise question: Is there a way to statically call
> "void" known functions ?
>
> Known functions are those that have prototype in any of <stdio.h>,
> <stdlib.h>, <string.h> or <math.h>, which are included in the C code
> of any open-cobol program ("free" is declared in <stdlib.h>).
>
> Since there less than 25 void functions in all these headers, we
> can live with it (wrap each needed function) if there is no better
> solution.
>
> Ehud.
>
> On Tue, 26 May 2009 19:36:26 vince coen wrote:
> > Hi;
> >
> > Just tried it using OC v1.1 and get:
> >
> > address@hidden Stock]$ ./test1
> > pntr=0x08056908
> > 123
> >
> >
> > What version of OC are you using?
> >
> > Shalom,
> >
> > Vince
> >
> > On Tuesday 26 May 2009, Ehud Karni wrote:
> > > Hello All,
> > >
> > > I'm the system programmer of Mivtach-Simon. One of the programmers
> > > here had a problem when he used CALL with void function like `free'.
> > >
> > > An example program:
> > >
> > > identification division.
> > > program-id. test-free.
> > > data division.
> > > working-storage section.
> > > 01 pntr usage pointer.
> > > 01 len-rec pic 999 value 100.
> > > linkage section.
> > > 01 rec pic x(100).
> > > procedure division.
> > > call "malloc" using value len-rec returning pntr.
> > > display "pntr=" pntr.
> > > set address of rec to pntr.
> > > move "123" to rec.
> > > display rec.
> > > call "free" using rec.
> > > move 0 to return-code
> > > stop run.
> > >
> > > The gcc emits the following error -
> > > test_free.c:140: error: void value not ignored as it ought to be
> > > which is referencing this produced c code:
> > > /* test_free.opc:15: CALL */
> > > {
> > > {
> > >
> > > module.cob_procedure_parameters[0] = (f_7.data = b_7, &f_7);
> > > module.cob_procedure_parameters[1] = NULL;
> > > module.cob_procedure_parameters[2] = NULL;
> > > module.cob_procedure_parameters[3] = NULL;
> > > module.cob_procedure_parameters[4] = NULL;
> > > cob_call_params = 1;
> > > (*(int *) (b_1)) = free (b_7); <--- error
> > > }
> > > }
> > >
> > > I checked the ISO standard (ISO/IEC 1989:200x WD 1.10) and did not
> > > find any syntax to say "not returning".
> > >
> > > The bypass solution now is to wrap the `free' call, like:
> > >
> > > int int_free (void *ptr)
> > > {
> > > free ( ptr ) ;
> > > return ( 0 ) ;
> > > }
> > >
> > > but we will appreciate a better non-specific solution.
> > >
> > > Ehud.
>
> --
> Ehud Karni Tel: +972-3-7966-561 /"\
> Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
> Insurance agencies (USA) voice mail and X Against HTML Mail
> http://www.mvs.co.il FAX: 1-815-5509341 / \
> GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [open-cobol-list] Problem calling a known void function,
vince coen <=