-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocessor.cpp
More file actions
46 lines (32 loc) · 977 Bytes
/
Copy pathpreprocessor.cpp
File metadata and controls
46 lines (32 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#define macro -name replacement - text
#define PI 3.14159
// function macro
#define MIN(a, b) ((a) < (b) ? (a) : (b))
// conditional compilation
#ifndef NULL
#define NULL 0
#endif
#ifdef DEBUG
std::cerr << "variable x = " << x << std::endl;
#endif
// #, ## operator
// # convert to string surrounded by quotes
// ## concatenate
#define MKSTR(x) #x
#define concat(a, b) a##b
// predefined C++ macros
// _LINE_, _FILE_, _DATE_, _TIME_
int main()
{
std::cout << PI << std::endl;
std::cout << "minimun is: " << MIN(10, 20) << std::endl;
std::cout << MKSTR(HELLO C++) << std::endl;
int xy = 100;
std::cout << concat(x, y) << std::endl; // will convert into xy
std::cout << "Value of _LINE_ :" << __LINE__ << std::endl;
std::cout << "Value of _FILE_ :" << __FILE__ << std::endl;
std::cout << "Value of _DATE_ :" << __DATE__ << std::endl;
std::cout << "Value of _TIME_ :" << __TIME__ << std::endl;
return 0;
}