我是C的新手,我正在维护代码.我在头文件中遇到过这个问题.我可以理解,如果源代码是在windows上编译的,它将进入if语句,如果代码在linux上编译,它将进入else语句.如果我错了,请纠正我.
但是,问题是为什么#(hash)在所有include头之前使用?
非常感谢任何建议,
#ifdef WIN32
# include <conio.h>
# include <process.h>
# include <stdlib.h>
# include <string.h>
#else
# include <unistd.h>
# include <termio.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
#endif
Run Code Online (Sandbox Code Playgroud)
散列(#)表示预处理器指令.预编译器在编译之前运行代码,并根据以"#"开头的所有行执行操作."#include filename.h"指令基本上复制了filename.h的所有内容,并将其粘贴到"#include filename.h"行所在的位置.
| 归档时间: |
|
| 查看次数: |
4206 次 |
| 最近记录: |