从标准头C编译器错误 - 未定义的C ++定义 [英] C Compiler error from standard headers - undefined C++ definitions

查看:107
本文介绍了从标准头C编译器错误 - 未定义的C ++定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译C程序,但收到许多错误。

I'm trying to compile a C program, but receive many errors.

在标准的C头文件(inttypes.h,stdio.h中,stat.h等)遇到的错误。

The errors are encountered in standard C headers files (inttypes.h, stdio.h, stat.h, etc).

错误的来源有以下几种常量未定义:

The source of the errors are the following undefined constants:

__ BEGIN_DECLS
__END_DECLS
__BEGIN_NAMESPACE_STD
__END_NAMESPACE_STD
__扔
__CONCAT

__BEGIN_DECLS __END_DECLS __BEGIN_NAMESPACE_STD __END_NAMESPACE_STD __THROW __CONCAT

什么这些常数似乎有一个共同点,就是他们是根据是否正在使用C或C ++编译器有不同的定义。

What these constants seem to have in common is that they are defined differently depending on whether the C or C++ compiler is being used.

例如,这个问题<一href=\"http://stackoverflow.com/questions/8087438/should-i-have-to-use-an-extern-c-block-to-include-the-c-headers/8087539#8087539\">this问题的示出了用于__BEGIN_DECLS以下定义

For example, this question this question shows the following definition for __BEGIN_DECLS

/* C++ needs to know that types and declarations are C, not C++.  */
#ifdef   __cplusplus
# define __BEGIN_DECLS  extern "C" {                                            
# define __END_DECLS }
#else
# define __BEGIN_DECLS
# define __END_DECLS
#endif

任何猜测,为什么我遇到了这些错误?

Any guesses as to why I'm encountering these errors?

推荐答案

我发现这个问题:

这些常数应该在sys / cdefs.h被定义。

These constants were supposed to be defined in sys/cdefs.h.

由于某种原因,这个文件是/usr/include/bsd/sys/cdefs.h。

For some reason this file was in /usr/include/bsd/sys/cdefs.h.

cdefs.h BSD版没有定义这些常量。

The bsd version of cdefs.h did not have these constants defined.

我删除了BSD目录中并重新安装的libc6-dev的。

I removed the bsd directory and reinstalled libc6-dev.

一切似乎是现在的工作。

Everything appears to be working now.

这篇关于从标准头C编译器错误 - 未定义的C ++定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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