Re: 4GL Debugger with global variables used by C code
Posted in 1997
Daniel Wright wrote: > > We have a program which is compiled from a 4GL source module and a C > module. > There is a global variable declared as "extern" in the C's header file, > as well as being declared in the GLOBALS of the 4GL. > This compiles and runs fine as far as that is concerned, BUT when using > the debugger, we are forced to compile a standalone executable (the > debugger program), which then uses the 4gi file containing the 4GL code. > Problem 1: We get unresolved symbol errors, since the variable is > declared externally. Two possible solutions: 1) (This is always good advice!) Avoid Global Variables like the plague. Keep the global in 4GL if there is no good way to pass the value around but pass it to the "C" module as an argument. Though I would lobby to give up the Global there as well if it can be done. If the "C" function needs to modify the 'global' just push the new value onto the return stack and let the 4GL calling function assign it to the real global. This is a MUCH better way to handle things as it severs the connection between the calling function and the called function. 2) Since the only problem is debugging why not compile the 4GL to "C" and debug it with the "C" debugger (dbx, gdb, adb, sdb). Of course this assumes that you have the C4GL compiler in addition to I4GL, and you should the I4GL run-time penalty can be as much as 25% for non-interactive programs and for calculation modules in screen programs, though I guess from the use of a C module that you know that already. Compiled 4GL tends to be MUCH faster reducing the need for C. Art S. Kagel