Thursday, July 9, 2009

What is # in #include in C,C++..?

It's for preprocessing in C/C++. The first stage in compiling a source code it's the pre-processing one. This part is located only at the begining of the code! It usually consists of:





a). include directives (#include "..." or #include %26lt;..%26gt;) which copies the full content of a file in the current code (the file is usually called a header file, for this reason)





b). define macros (#define max(a,b) a%26gt;b?a:b for example), meaning that during the pre-procesing stage each macro call is replaced, in-line, by the corresponding macro definition (in this case if in the code i would type z=max(a,b) the compiler will change max(a,b) with it's definition given above, so it will write z=a%26gt;b?a:b )





c). define conditional compilation (which permits having different versions of the source code in the same file). Typically, this is used to customize the program with respect to the compilation platform, the status (work-in-progress/production code), as well as to ensure that header files are only included once.


#ifdef x


...


#else


...


#endif , or





#if x


...


#else


...


#endif

What is # in #include in C,C++..?
huh?
Reply:i forgot
Reply:This is the " Pre-Processor Directive".


Put on top of the code to direct what header files we wish to use.
Reply:# is the preprocessor directive which commands that the content of file %26lt;stdio.h%26gt; should be included at the time of compilation.





%26lt;stdio.h%26gt; is the header file which contains all input and output functions like scanf(), printf() which are frequently used in c programs.
Reply:Syntax





#INCLUDE FileName





Arguments





FileName





Specifies the name of the header file that is merged into the program during compilation.





You can include a path with the header file name. When you include a path with the header file name, Visual FoxPro searches for the header file only in the specified location.





If you do not include a path with the header file name, Visual FoxPro searches for the header file in the default Visual FoxPro directory, and then along the Visual FoxPro path. The Visual FoxPro path is specified with SET PATH.





Remarks





You can create header files containing preprocessor directives and then use #INCLUDE to merge the contents of the header file into a program when the program is compiled. The contents of the header file are inserted into the program during compilation at the point where #INCLUDE appears in the program.





Only the #DEFINE ... #UNDEF and #IF ... #ENDIF preprocessor directives are recognized in a header file. Comments and Visual FoxPro commands included in a header file are ignored.





A program can contain any number of #INCLUDE directives. These directives can appear anywhere within the program. #INCLUDE directives can also appear in header files, allowing you to nest #INCLUDE directives.





Header files typically have an .h extension, although they can have any extension. A Visual FoxPro header file, Foxpro.h, is included. It contains many of the constants described throughout this documentation.
Reply:WHAT?
Reply:It just signals that a compiler directive is coming up.

sp

No comments:

Post a Comment