• Advertisement

Archived

This topic is now archived and is closed to further replies.

extern -- what does it mean and why is it used?

This topic is 5344 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

In Nehe''s lesson 31, there is a header file that contains: extern GLuint LoadGLTexture( const char *filename ); // Load Bitmaps And Convert To Textures What does "extern" mean? Why create a seperate header file (there are other header files in this lesson) for just this one line?

Share this post


Link to post
Share on other sites
Advertisement
extern means, in your code, that your function is declared here, but defined in another file (i believe).

the Seby

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
// file.cpp

// global variable
int x;

// ----------------------------------------------

// otherFile.cpp

extern int x; // allow access to global variable x from file.cpp

Share this post


Link to post
Share on other sites
quote:
Original post by Agape
In Nehe''s lesson 31, there is a header file that contains:

extern GLuint LoadGLTexture( const char *filename ); // Load Bitmaps And Convert To Textures


What does "extern" mean? Why create a seperate header file (there are other header files in this lesson) for just this one line?


I think that a function prototype is extern by default, so the extern is unneeded in this case. You only really need it for variables (which are not extern by default).

Share this post


Link to post
Share on other sites

  • Advertisement