Pretreatment
1 Macro Definitions
2 file contains
3 conditional Compilation
1 Macro Definitions
Software engineering rules, macro definition in English capital
Define does not perform type checking and is only replaced, so some situations can go wrong.
As far as possible without define, when initialized with Const,const, will be automatically type conversion, there will be type check
1 #define_crt_secure_no_warnings2 3#include <stdio.h>4#include <stdlib.h>5 6 #defineM 10.07 8 Main ()9 {Ten Const intN =10.9; One Aprintf"%d\n", M);//define does not perform type checking and is only replaced, so some situations can go wrong. - -printf"%d\n"+ i);//as far as possible without define, when initialized with Const,const, will be automatically type conversion, there will be type check the -System"Pause"); -}
3 conditional Compilation
1 #define_crt_secure_no_warnings2 3#include <stdio.h>4#include <stdlib.h>5 6 #defineCN "Hello World"7 #defineEn "Hello World"8 9 #defineB 1//define a macro that has a selection of compiled statements, such as a set of encodings that should be two versions in both English and ChineseTen One Main () A { - - #ifB = = 1 the { - printf (CN); - } - #else + { - printf (en); + } A #endif at -System"Pause"); -}
Classical Algorithm _ Preprocessing