[gameprogrammer] Re: C-Code Error interpretation
- From: Scott Harper <lareon@xxxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Sun, 31 Jul 2005 19:57:00 -0600
Okay, so I checked the usage throughout the project (I love XCode),
and the variable ONLY occurs in the header file and the one source
file... Would it be more proper to remove the reference to the file
in the header, then, rather than remove the static keyword? (Sorry,
like I said, I'm generally a Java programmer, and I'm looking into
taking some classes on C so I can understand all of these
complexities better.)
--Scott
On 31 Jul, 2005, at 7:43 PM, Dave Slutzkin wrote:
On Sun, 31 Jul 2005 19:19:48 -0600, "Scott Harper"
<lareon@xxxxxxxxxxx>
said:
Sorry to bother, but I'm trying to get some code compiling so I can
start working with it, but I'm running into some errors (two left
now, actually) that I don't understand how to resolve.
First off, there's "static declaration of 'variable_name' follows
non-
static declaration", and then it links back to both places it's
declared:
*.h -- extern int variable_name;
*.c -- static int variable_name;
Static says to the linker 'no need to make this accessible outside
this
file'. Extern says to the linker 'find this in another file'. As I
understand it, the linker should complain, because (I can't
remember the
terminology exactly) the variable hasn't been declared with external
linkage, so other compilation units shouldn't be able to access it.
Does this make sense?
So I think the fix is to just get rid of the static from the
declaration. Obviously the Microsoft linker is slightly non-standard
here.
Hope that helps,
Dave.
--
Dave Slutzkin
Melbourne, Australia
daveslutzkin@xxxxxxxxxxx
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: C-Code Error interpretation
- From: Robbert de Groot
- References:
- [gameprogrammer] C-Code Error interpretation
- From: Scott Harper
- [gameprogrammer] Re: C-Code Error interpretation
- From: Dave Slutzkin
Other related posts:
- » [gameprogrammer] C-Code Error interpretation
- » [gameprogrammer] Re: C-Code Error interpretation
- » [gameprogrammer] Re: C-Code Error interpretation
- » [gameprogrammer] Re: C-Code Error interpretation
- » [gameprogrammer] Re: C-Code Error interpretation
said:
Sorry to bother, but I'm trying to get some code compiling so I can start working with it, but I'm running into some errors (two left now, actually) that I don't understand how to resolve.
First off, there's "static declaration of 'variable_name' follows non-
static declaration", and then it links back to both places it's
declared:
*.h -- extern int variable_name; *.c -- static int variable_name;
Static says to the linker 'no need to make this accessible outside this
file'. Extern says to the linker 'find this in another file'. As I
understand it, the linker should complain, because (I can't remember the
terminology exactly) the variable hasn't been declared with external
linkage, so other compilation units shouldn't be able to access it.
Does this make sense?
So I think the fix is to just get rid of the static from the declaration. Obviously the Microsoft linker is slightly non-standard here.
Hope that helps,
Dave. -- Dave Slutzkin Melbourne, Australia daveslutzkin@xxxxxxxxxxx
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- [gameprogrammer] Re: C-Code Error interpretation
- From: Robbert de Groot
- [gameprogrammer] C-Code Error interpretation
- From: Scott Harper
- [gameprogrammer] Re: C-Code Error interpretation
- From: Dave Slutzkin