#define 宏函数
预定义符号表:
符号 | 示例 | 含义 |
__FILE__ | /home/david/hello.c | 正在预编译的源文件名 |
__LINE__ | 5 | 文件当前的行号 |
__FUNCTION__ | main | 当前所在的函数名 |
序表:
符号 | 示例 | 含义 |
__DATE__ | Mar 01 2016 | 预编译文件的日期 |
__TIME__ | 23:04:12 | 预编译文件的时间 |
__STDC__ | 1 | 如果编译器遵循ANSIC,则值为1 |
#define INFO(format,...) printf("FILE: "__FILE__ ", LINE: %d: " format "\n", __LINK__, ##__VA_ARGS__)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#if defined(_WIN16) || defined(__MSDOS__) || defined(_MSDOS)
// 16 bit systems use long int for 32 bit integer
typedef long int int32; // 32 bit signed integer
typedef unsigned long int uint32; // 32 bit unsigned integer
#else
// Most other systems use int for 32 bit integer
typedef int int32; // 32 bit signed integer
typedef unsigned int uint32; // 32 bit unsigned integer
#endif
// Define 64 bit signed and unsigned integers, if possible
#if (defined(__WINDOWS__) || defined(_WIN32)) && (defined(_MSC_VER) || defined(__INTEL_COMPILER))
// Microsoft and other compilers under Windows use __int64
typedef __int64 int64; // 64 bit signed integer
typedef unsigned __int64 uint64; // 64 bit unsigned integer
#define INT64_DEFINED // Remember that int64 is defined
#elif defined(__unix__) && (defined(_M_IX86) || defined(_M_X64))
// Gnu and other compilers under Linux etc. use long long
typedef long long int64; // 64 bit signed integer
typedef unsigned long long uint64; // 64 bit unsigned integer
#define INT64_DEFINED // Remember that int64 is defined
#else
// 64 bit integers not defined
// You may include definitions for other platforms here
#endif