Jump to content

Image of the Day

#animation 2/14

Sweet piggy, isn't it?

#gamedev #indiedev #indiegame #GamersUnite #screenshotsaturday #unity3d https://t.co/lscyvCxrPR
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

static variables name clash

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 noatom   Members   

919
Like
0Likes
Like

Posted 31 March 2013 - 07:18 AM

So I have an exercise in my book that says: prove that file static variables in header files don't clash with each other when included in more than one cpp file.

 

So I have a header file that contains just: int i=10;

and 2 cpp files that include that header file.

 

When i try to compile->fatal error LNK1169: one or more multiply defined symbols found



#2 Hodgman   Moderators   

50154
Like
0Likes
Like

Posted 31 March 2013 - 07:24 AM

That should probably be static int i=10;



#3 Bacterius   Members   

13144
Like
0Likes
Like

Posted 31 March 2013 - 07:26 AM

Also, it's probably not a good idea to call a global variable "i". Such a variable name is very common for loops or other things.


“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”


#4 noatom   Members   

919
Like
0Likes
Like

Posted 31 March 2013 - 07:26 AM

yea...you are right...damn






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.