gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] Problem calling a known void function


From: Roger While
Subject: Re: [open-cobol-list] Problem calling a known void function
Date: Wed, 27 May 2009 19:28:03 +0200

The upcoming 1.1 tarball (probably at the weekend) will allow
the syntax -
CALL ....   RETURNING NULL.

Please also note that the static-call option is deprecated
(it does not appear in the cobc --help) and will be removed at
some stage.

You should also ask yourself why you are resorting to
call system routines. More often than not there is
a COBOL equivalent.
eg. there is FUNCTION RANDOM.

Note also that if you just want temporary storage for the duration
of the program, then you can define fields in the
LOCAL-STORAGE SECTION.
These are dynamically acquired (and initialized) on entry to the program
and freed on exit from the program.

Messing around with COB_CFLAGS is NOT encouraged and,
most certainly, redefining standard library calls will lead to disaster.

Roger

On Wed, 27 May 2009 12:39:21 Roger While wrote:
>
> Use COBOL syntax for doing this -
>
>         identification division.
>         program-id. test-free.
>         data        division.
>         working-storage section.
>         01 rec pic x(100) BASED.
>         procedure  division.
>             ALLOCATE rec.
>             move "123" to rec.
>             display rec.
>             FREE rec.
>             move 0 to return-code
>             stop run.

Thank you for your quick answer. We will look into it and use the COBOL
syntax, but for now (while migrating) we have reasons to keep it the
way it is. We have found a general workaround (e.g. for `srandom'):

Create a header file "void_fix.h" like this:

#define free dummy_free
#define srandom dummy_srandom
#include <stdlib.h>
#undef free
#undef srandom
/* the open-cobol compilation works even without prototype */
int free (void *ptr) ;
int srandom (unsigned int seed) ;


and for compilation do:

CWD=`pwd`
COB_CFLAGS="-include $CWD/void_fix.h"
export COB_CFLAGS
....compile as before....


Ehud.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]