Code
#include <iostream>
#define PI 3.1415
#define MULT(a, b) ((a) * (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MAX1(a, b) \
[&]() { \
decltype(a) _a = a; \
auto _b = b; \
return _a > _b ? _a : _b; \
}()
#define NULL 0
#define WITH_EDITOR 0
#define CONFIG 101
void f(int* ptr)
{
std::cout << "ptr" << std::endl;
}
void f(int integer)
{
std::cout << "integer" << std::endl;
}
int main()
{
const double r = 10.0;
const double circleArea = PI * r * r;
const char* coolString = "PI value";
const char* coolPIString = "PI value";
const int result = MULT(10 + 9, 13);
int max = MAX(1, 2);
int a = 11;
int b = 22;
max = MAX(a++, b--);
std::cout << max << std::endl;
std::cout << a << std::endl;
a = 11;
b = 22;
max = MAX1(a++, b--);
std::cout << max << std::endl;
std::cout << a << std::endl;
int* ptr = NULL;
int integer = NULL;
f(NULL);
f(nullptr);
bool isEditor = false;
#ifdef WITH_EDITOR
isEditor = true;
#else
isEditor = false;
#endif // WITH_EDITOR
enum class Config
{
Debug = 0,
Release = 1
} config;
#ifdef CONFIG
#if CONFIG == 100
config = Config::Debug;
#elif CONFIG == 101
config = Config::Release;
#else
#error "Unknown configuration"
#endif
#endif
}Last updated