Problem:
When attempting to call a C function such as "time" directly from a Net Express program linked as an .exe, a 173 error is returned on the call. How can I get the call to find these C system functions?
Resolution:
In order to call C functions such as "time" directly from a linked Net Express executable, you either need to specify the litlink option for the call so the function will be resolved at link time to the MSVCRT.LIB import library or you need to load the C library dynamically at run-time.
Example:
call "time" using by reference time-row
If you compile this for .int/.gnt then it should be found OK as the C run-time will be loaded automatically and the entry point will be available.
If you are linking your program as an .exe/.dll then you must load the C run-time support manually in order to make these entry points available..
You can do this dynamically at run-time by using the following:
01 pp procedure-pointer.
set pp to entry "MSVCRT"
call "time" using by reference time-row
An alternative to this approach is to use the following directive when compiling:
$set initcall"cob32api"
You can also resolve these entry points at link time by adding the following directives to the compile:
$set case litlink
This will force the call to be resolved in the link library MSVCRT.LIB which is automatically referenced during the build.
If you do not want all call literal statements in your program to be litlinked you can selectively use a call-convention for only the C functions.
Use $set case directive and then use call-convention 8 as shown here:
special-names.
call-convention 8 is litlink.
call litlink "time" using reference time-row.
#173error
#LITLINK
#Cfunction
#callC