C Compiler error from standard headers - undefined

2020-04-30 20:44发布

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

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 __THROW __CONCAT

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.

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?

标签: c++ c linux ubuntu
1条回答
我想做一个坏孩纸
2楼-- · 2020-04-30 21:30

I found the problem:

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

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

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

I removed the bsd directory and reinstalled libc6-dev.

Everything appears to be working now.

查看更多
登录 后发表回答