Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   "extern" linking issues. (http://www.chiefdelphi.com/forums/showthread.php?t=51932)

xrabohrok 15-01-2007 15:20

"extern" linking issues.
 
It's me and my silly errors again. This time it has to do with variable types.
This error originates from trying to use an "extern" variable extension to get data from the tracking.c file. This should theoretically work, but it doesn't.

I get an error that reads (abridged):
Fatal[151] -internal- populateExternalReferences() -symbol 'virtual_servo_tilt' is not an external reference.

I declare both instances of the variable in each file, I used a .h file to declare the variable, and I include the .h file in both .c files. (For the record, it's tracking.h).

You guys have been wonderfully patient with me, and I thank you people.

JSonntag 15-01-2007 15:51

Re: "extern" linking issues.
 
go to the .c file that you are trying to get the data to and at the top, declare an extern variable that is the same name as the variable in the tracking.c file.

example:

say in tracking.c i have a global variable called servo_position that i want to get to user_routines.c

i just go to user routines and type:

extern unsigned char servo_position;

then i can use the variable in user_routines.c

you do not put extern in front of the variable in tracking.c or else you will get an error

Mike Betts 15-01-2007 16:00

Re: "extern" linking issues.
 
You probably have something like "extern int myvariable;" in each file.

Note that you must also have "int myvariable" in one file (the owner of the variable) and it should be global and static in scope (not embedded in a function).

Regards,

Mike


All times are GMT -5. The time now is 01:27.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi