如何使用clang在OS X上使用c11标准库进行编译? [英] How to compile with c11 standard library on OS X with clang?

查看:139
本文介绍了如何使用clang在OS X上使用c11标准库进行编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在尝试编译使用带有clang的OS X上c11标准库中的函数的c代码.

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

编译器选项 -std = c11 允许我使用c11语言功能.但是,当我使用 at_quick_exit 之类的新功能时,收到以下警告函数'at_quick_exit'的隐式声明在C99中无效.

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.

源代码包含以下行 #include< stdlib.h> 铛选项 -stdlib 没有帮助.

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

OS X优胜美地10.10.3

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

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

更明确.如何在OS X上获得c11标准库?

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

感谢任何帮助.

推荐答案

通常,仅自托管的系统编译器无法提供完整的Standard C环境,包括运行时库.通常,底层系统提供大多数(如果不是全部)库(和标头),而编译器仅进行编译.

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.

在这种特殊情况下,您可能还会发现系统的 libc 本身未提供 quick_exit()本身,因此编写这两个函数应该足够容易靠你自己.

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.

这篇关于如何使用clang在OS X上使用c11标准库进行编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆