1: We often see the way the header files are written:
#ifdef my_head_h__ #define my_head_h__#endif
This is to prevent the duplicate definition of the file, the preprocessor comes back to process the header files, when he first processed the header file, found that my_head_h__ has not been defined, so that will compile the content of the macro under the condition. If the file is referenced multiple times, the preprocessor will find that my_head_h__ is already defined, so you can skip the content under that condition. In particular, the name of the same time, you can effectively prevent "symbol already defined" compilation errors, usually, we use the capitalization of the header file as the same names, to avoid the same names as other header files in the project. 2: About the __attribute__ mechanism: refer to the http://www.cnblogs.com/astwish/p/3460618.html, the time to check again I have only seen the following usage, is used to eliminate GCC- Wall The warning of a function of a non-null type with no return value in the option
/**/#define noreturn __attribute__ ((__noreturn__))#else#define Noreturn#endif
3: Used to concatenate strings, or to enclose numbers or strings in quotation marks or single quotes
/* complete two x and y stitching */ #define Conn (x, y) x# #y/* with x plus single quote variable character, x length must not exceed four, possibly because one character translates up to 4 bits */#define tochar (x) #@x /* Add double quotes to x and turn into a string */ #define ToString (x) #x/* defines a macro function that needs to be spliced with \ /#define// function body \ }
4: Using Macros for debugging (only to discuss the use of logs) predefined macros have __file__, __line__,__date__,__time__, words can know the meaning of the string they represent, have been tested------------------------- -----------written here first, and then updated with usage---Thursday, March 10, 2016-----------------------------------
Http://blog.chinaunix.net/uid-22566367-id-381995.html
Http://www.cnblogs.com/gaojian/p/3167451.html
http://blog.csdn.net/zhangxinrun/article/details/5808788
Http://www.cnblogs.com/flywuya/archive/2010/12/04/1896121.html
Header files that you have to know about.