Sunday, December 17, 2017

What is a preprocessor directive in c programming language

Preprocessor directives


Preprocessor directives units 



C language programming  preprocessor directives are the  to it that you also familiarize yourself with these preprocessor directives so that you can write working programs in the C language.
         Preprocessor  directives are lines included in  the code of  our programs  that are not program statements but   directives for the preprocessor. 
                These lines are always  preceded  by a pound sign (#). The preprocessor is  executed  before the actual  compilation  of code begins,  therefore the  preprocessor digests all these directives  before any code is generated by the statements.  
                    These preprocessor directives extend only  across a   single  line of  code. As soon as a newline character is  found,  the preprocessor directive is considered to end.  
                 No semicolon  (;) is  expected at the end of a preprocessor  directive. 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 (\).

 For example:-
    
standard macro names 

#include <iostream> 

using  namespace  std; 

int  main() 

{   

cout <<  "This is the line number "  << __LINE__;  

 cout <<  " of file "  << __FILE__ <<  ".\n";  

 cout <<  "Its compilation began " << __DATE__;  
Hi
 cout <<  " at "  << __TIME__ << ".\n";  

 cout <<  "The compiler gives a __cplusplus value of "  << 

__cplusplus;

 return  0;

 } 


Their are some  preprocessor directives name and its used:-

1).  #include:-
            it undefines a symbol that has been previously defined 

2). #define – 
         it defines a preprocessor symbol or macro 

3). #if –
        it tests for conditional compilations    

4). #ifndef – 
          it tests for conditional compilations 

5). #ifdef – 
            it tests for conditional compilations 

6). #endif – 
            it tests for conditional compilations 

7). #else –
             it tests for conditional compilations 

8). #error – 
          it is a tool for debugging 

9). #line – 
          it is a tool for debugging

10). #Pragma-
               Their are directives used in specify diverse option.

0 comments:

Please comment and follow this site blog inbox