Jump to content
  • Advertisement
Sign in to follow this  
BloodLust666

extern

This topic is 4792 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

if i have an extern variable. can i declare the extern (ex: extern long Var) in many files? or can i declare the actual variable (long Var) in many files?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by LessBread
Declare the actual variable in one file and use extern in many other files to access it.

<pedantic>define the variable in one file and use extern declarations to access it from other files.

When you have just
long Var;
it's a definition and can only show up (in a given namespace scope) once in your entire program.

When you have
extern long Var;
it's a declaration and can show up in as many files or as many times in one file as you want.
</pedantic>

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!