#if defined(_WIN64) // 64-bit programs run only on Win64 #elif defined(_WIN32) // 32-bit programs run on both 32-bit and 64-bit Windows #else // Win64 does not support Win16 #endif
#ifdef _WIN64 #else #endif
#define TRACE(n) printf("TRACE: %d\n", n)
the predefined ANSI C and Microsoft C++ implementation macros
__LINE__ __FILE__ __DATE__ __TIME__Simple Example :
Example 1 :msdn.microsoft.com
hello world .
#define DEBUG(x) do { if (flag) { std::cerr << x; } } while (0)
Example 2 : debugging
Example 3. Preprocessor directives.
#define :
call macro .
a = 20
b = 10
call function .
a = 10
b = 20
Press any key to continue . . .
Note :
Function and "#define" preprocessor are very different .
+ The "#define" is called , compiler will copies code . So when compiler copies code, size of code will increase, But program will run more quickly.
+ The function is called , Compiler will accesses to address of this function .So When compiler accesses function , size of code will not change , but program will run slowly.
This are some normally errors about "#define " preprocessor
#define square(x) x * x To #define square(x) ((x) * (x))
#include #include <iostream>
#include "MyFunction.h"
#include "../FolderName/FolderName1/test.h"
#pragma
#if defined(UNICODE)
#define _tcout wcout
#else
#define _tcout cout
#endif
int _tmain(int argc, TCHAR* argv[])
{
for (int c = 0; c < argc; c++)
{
_tcout << argv[c] << " ";
}
return 0;
} ThongLT - letrthong@gmail.com
http://c-faq.com/cpp/index.html
http://support.microsoft.com/kb/153901
No comments:
Post a Comment