Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
why we are using a # before include(#include)or in front of preprocessors?_
Posted
Comments
Volynsky Alex 24-Sep-12 11:45am    
Please try to read following links:
http://en.wikipedia.org/wiki/Preprocessor_directive
http://www.tenouk.com/Module10.html

Using the # character in C like languages is part of the language definition. Usually this symbol is used for any directives that are used by the preprocessor. I guess there is no special reason why the original creators of C used the # symbol.
Read this Wikepedia article for more information about the C preprocessor:
http://en.wikipedia.org/wiki/C_preprocessor[^]
 
Share this answer
 
Because the preprocessor must know which are its commands.
Using a 'special character' like # prevents name collisions with the compiler.
 
Share this answer
 
It makes it easier for both humans and computers to recognize which lines are preprocessor directives if they all start that way (think about it, if you're going through looking for preprocessor commands, it will be a lot easier if every line you're looking for starts with #). I don't think there's a particular reason # was chosen, besides the fact that it isn't used anywhere else in the language (that I can think of). It might be related to the fact it's a comment in most Linux/Unix shell scripts.
 
Share this answer
 
In the C and C++ programming languages, an #include guard, sometimes called a macro guard, is a particular construct used to avoid the problem of double inclusion when dealing with the include directive. The addition of #include guards to a header file is one way to make that file idempotent.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900