Click here to Skip to main content
Sign Up to vote bad
good
See more: C++C
why we are using a # before include(#include)or in front of preprocessors?_
Posted 23 Sep '12 - 18:48

Comments
Volynsky Alex - 24 Sep '12 - 11:45
Please try to read following links: http://en.wikipedia.org/wiki/Preprocessor_directive http://www.tenouk.com/Module10.html

4 solutions

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[^]
  Permalink  
Because the preprocessor must know which are its commands.
Using a 'special character' like # prevents name collisions with the compiler.
  Permalink  
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.
  Permalink  
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.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 216
1 Sergey Alexandrovich Kryukov 169
2 Tadit Dash 154
3 Richard MacCutchan 145
4 Santhosh G_ 115
0 Sergey Alexandrovich Kryukov 10,338
1 OriginalGriff 7,965
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,159


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid