GhaSShee


CPP


CPP := The C Preprocessor ================================================= `#include` statement ------------------------------------------- ~~~c #include int main(void) { printf("Hello, world!\n"); } ~~~ The preprocessor $ replace $ the line `#include ` with the text contents in the standard library file 'stdio.h'. Double quotes `#include "stdio.h"` denotes the search path for the file is expand to include the current directory. `#if` statements ------------------------------------------ ~~~c #if #ifdef #ifndef #else #elif #endif ~~~ `#define` statements --------------------------------------------- ~~~c #define PI 3.14159 #define RADTODEG(x) ((x) * 57.29578) #undef PI ~~~ Debugging feature --------------------------------------------- ~~~c __FILE__ ## filename __LINE__ ## current line __STDC__ ## 1 if the implementation confirms ISO standard __STDC_VERSION__ __DATE__ __TIME__ ~~~ Operator `#` := Token stringification ------------------------------------------------ ~~~c #define xstr(s) str(s) #define str(s) #s #define foo 4 str (foo) // "foo" xstr (foo) // "4" ~~~ !!! Tip `##` operator denotes "concatenation" `#pragma` statement ---------------------------------------------------------- ~~~c #pragma ## compiler-specific derective ~~~ A compiler with support for the OpenMP parallelization can parallelize a for loop automoatically ~~~c #pragma omp parallel for ~~~