c problem

Started by
5 comments, last by y2jsave 15 years, 10 months ago
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 )
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.
------------Anything prior to 9am should be illegal.
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....

ok ,
but still is the first underscore of _STDIO_H_

related to being a global variable or something like that?
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.
-------------Please rate this post if it was useful.
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.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

thanks a lot

This topic is closed to new replies.

Advertisement