为什么 c/c++ 中没有针对不存在的包含文件的错误修复程序?

问题描述 投票:0回答:1

在c/c++中区分操作系统有很多困难。也就是说,我注意到不同的操作系统有非常特定的库,windows 中的 windows.h,linux 中的 unist.h 或 time.h 等等...

为什么没有使用?:

#tryinclude
#include "win-app.c"
#catch
#include "unix-app.c"
#endtry

int main(){...}
c c++ standards
1个回答
0
投票

没有! 解决方法是使用操作系统预定义的宏。它们应该由您的编译器记录。

#ifdef sparc
#include "sparc.h"
#elif defined vax
#include "vax.h"
#else
#error OS not supported at the moment
#endif
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.