C Global Variables and their scope

In article <4kcfi8$ka7@ren.fp.co.nz>, webbj@fp.co.nz says...
>
>Does anyone know what scope the global variables in a C procedure 
>compiled from ABF is?

They are global to the whole image, if they're not static.  For example,
if you have

	int my_total = 0;
	int
	my_proc(int value)
	{
	    return my_total += value;
	}

in a C procedure defined to ABF, my_total and my_proc are completely 
global, and you could refer to them in another C procedure.  If 
they are redefined in another C procedure, linking errors will occur.

>We are getting these strange linking errors when trying
>to compile an image and the offending symbols seem to be the global 
>variables (that is, those variables global to the C procedure itself).

ABF's linking is quite straightforward, (except that the link commands 
can be enormous for a large application), and the symbols it generates in 
its C code are usually prefixed with II.  Perhaps your C procedures are 
including headers that clash with library routines that Ingres use, or 
require libraries that redefine routines used by Ingres.

If your C procedures are redefining globals, it sounds like somebody's 
been sloppy and the addition of a few "extern" or "static" keywords would 
help.

If you really need to track this down, you may have to get into your 
linker's man page (or equivalent) and modify 
$II_SYSTEM/ingres/files/utld.def to set flags that will tell you what's 
going on.
-- 
John Little
Auckland, New Zealand, phone (64) (9) 575 4621
                       e-mail jlittle@iconz.co.nz
Ingres Q & A
To William's Home Page

© William Yuan 2000

Email William