
This directive is used to specify diverse options to the compiler. In the case that the file is not found, the compiler interprets the directive as a header inclusion, just as if the quotes ( "") were replaced by angle-brackets ( ). The file is searched for in an implementation-defined manner, which generally includes the current path. The syntax used in the second #include uses quotes, and includes a file. Whether the headers are actually files or exist in some other form is implementation-defined, but in any case they shall be properly included with this directive. This is used to include headers provided by the implementation, such as the headers that compose the standard library ( iostream, string.). In the first case, a header is specified between angle-brackets. The preprocessor does not understand C++ proper, it simply replaces any occurrence of identifier by replacement. This replacement can be an expression, a statement, a block or simply anything. When the preprocessor encounters this directive, it replaces any occurrence of identifier in the rest of the code by replacement. To define preprocessor macros we can use #define. The only way a preprocessor directive can extend through more than one line is by preceding the newline character at the end of the line by a backslash ( \). No semicolon ( ) is expected at the end of a preprocessor directive. As soon as a newline character is found, the preprocessor directive is ends. These preprocessor directives extend only across a single line of code. The preprocessor examines the code before actual compilation of code begins and resolves all these directives before any code is actually generated by regular statements. These lines are not program statements but directives for the preprocessor. At the time of compilation, compiler will replace the macro SUM with its code fragment (A+B).Preprocessor directives are lines included in the code of programs preceded by a hash sign ( #). Here, SUM is complex macro where A and B are the input arguments and the statement (A+B) is the code fragment which. code_fragment is the statement which is compiled at the place of the macroĬonsider the following statement (as example code of complex macro) #define SUM(A,B) (A+B).Syntax #define macro_name( argument_list) code_fragment This type of macro seems like a function hence we can say that this is the "Function Like Macro Definition". These values pass in the macro definition with the help of arguments.Īrguments must be used each time of macro calling. We can also define a macro with arguments, so that a macro may use at different places with different values. Here, we will learn how we can define a complex macro which looks like a user define function in c programming language?
