接触过C/C++编程的应该一定知道条件编译。通常为了满足不同环境下使用不同的代码,从而在编译的时候进行选择性的编译,达到最佳的泛用性。
例如:
#define WINDOWS
#ifdef WINDOWS
# include <windows.h>
#elif defined LINUX
# include <sys/types.h>
# include <sys/stat.h>
# include <unistd.h>
# include <fcntl.h>
#endif
接触过C/C++编程的应该一定知道条件编译。通常为了满足不同环境下使用不同的代码,从而在编译的时候进行选择性的编译,达到最佳的泛用性。
例如:
#define WINDOWS
#ifdef WINDOWS
# include <windows.h>
#elif defined LINUX
# include <sys/types.h>
# include <sys/stat.h>
# include <unistd.h>
# include <fcntl.h>
#endif