简体   繁体   English

有没有办法只编译POSIX API

[英]is there a way to ONLY compile POSIX API

I am developing a system that must be fully POSIX compatible 我正在开发一个必须完全兼容POSIX的系统

I am developing this on Fedora Core 14 with gcc and c++ 我正在使用gcc和c ++在Fedora Core 14上开发它

I do not want to use anything that is not POSIX 我不想使用任何不是POSIX的东西

How do I ensure I maintain this? 我如何确保我保持这个?

is there a compiler setting? 有编译器设置吗?

I am using Codeblocks 我正在使用Codeblocks

No, there's no "magic compiler switch" to insure you use only Posix APIs. 不,没有“神奇的编译器开关”来确保您只使用Posix API。

You can get the POSIX spec here: 你可以在这里获得POSIX规范:

This suite allows you to check your application for conformance to the POSIX API: 该套件允许您检查您的应用程序是否符合POSIX API:

This does not really have anything to do with the compiler. 这与编译器没有任何关系。 POSIX specifies utilities, interfaces and the accompanying header files - the compiler is only concerned with the specifics of the programming language. POSIX指定实用程序,接口和附带的头文件 - 编译器只关注编程语言的细节。

That said, if the header file set that you are using is well-implemented you should be able to enable/disable the feature sets that you are using with proper -D and -U options for gcc . 这就是说,如果您正在使用头文件集是实现良好的,你应该能够启用/禁用您正在使用适当的功能集-D-U的选项gcc

For example including fcntl.h will not allow access to fallocate() unless _GNU_SOURCE has been defined. 例如包括fcntl.h将不允许访问fallocate()除非_GNU_SOURCE已被定义。 With the same header, you need to define _POSIX_C_SOURCE to 200809L or greater for the F_DUPFD_CLOEXEC fcntl() to be available. 使用相同的标头,您需要将_POSIX_C_SOURCE定义为200809L或更高,以使F_DUPFD_CLOEXEC fcntl()可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM