Jump to content
  • Advertisement
Sign in to follow this  
y2jsave

c problem

This topic is 3705 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 stdio.h the first two lines are : #ifndef _STDIO_H_ #define _STDIO_H_ these i suppose are so that we can include it several times in our c project which has 2 or more .c files and which include stdio.h but what is the significance of _STDIO_H_ ( why this strange name )

Share this post


Link to post
Share on other sites
Advertisement
There is no significance. You can name that Macro whatever you like, just as long as its unique. Using the filename of the header as the macro is one way to be unique.

Share this post


Link to post
Share on other sites
there is no significance, it just has to be unique - with any luck _STDIO_H_ wouldn't be used as a variable or function name. It could be

_BAA_BAA_BLACK_SHEEP_HASNT_ANY_WOOL__H_

and still work....

Share this post


Link to post
Share on other sites
ok ,
but still is the first underscore of _STDIO_H_

related to being a global variable or something like that?

Share this post


Link to post
Share on other sites
The first underscore is probably just there to make it less likely that the same identifier is used somewhere else. When people say that there is no significance to the name, they mean that there really is no significance to the name.

Share this post


Link to post
Share on other sites
On Underscores
Quote:
From the article
This practice was later codified as part of the C and C++ language standards, in which the use of leading underscores was reserved for the implementation.


What that means is that the compiler can use leading underscores as often as they'd like to limit the odds that you, the user of the compiler, will not have any conflicts provided that you yourself don't use leading underscores. So if there is any significance that is probably it. I don't believe either C nor C++ standard dictates a particular naming convention for standard library header guards.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!