How to compile with c11 standard library on OS X with clang?

折月煮酒 提交于 2019-12-13 01:33:17

问题


Hey I am trying to compile c code that uses functions from the c11 standard library on OS X with clang.

The compiler option -std=c11 allows me to use c11 language features. But when I am using new functions like at_quick_exit I get the following warning implicit declaration of function 'at_quick_exit' is invalid in C99.

The source code has the following line #include <stdlib.h> The clang option -stdlib does not help.

My Systems:

OS X Yosemite 10.10.3

$ clang -v
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

Ubuntu 14.04 LTS

$ clang -v
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu 
Thread model: posix

To be more explicit. How can I get on OS X a c11 standard library?

Thanks for any kind of help.


回答1:


Typically a self-hosted system compiler alone does not provide the full Standard C environment including runtime libraries. Typically the underlying system provides most, if not all, of the libraries (and headers), while the compiler just compiles.

So, if you need some specific functions that are not provided on a given system then you will have to write them yourself, or source them from some portable library that is compatible with your target system.

In this particular case you will also probably find that quick_exit() itself is not provided by the system's libc, and so it should be easy enough to write both functions on your own.



来源:https://stackoverflow.com/questions/30408197/how-to-compile-with-c11-standard-library-on-os-x-with-clang

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!