9
extern "C" 
{
#endif
#include <stdint.h>
#include <limits.h>
#include "attributes.h"
}
#endif

我添加了extern "C" { } 然后我得到了C2059 string错误所以我尝试使用#endif,现在我还有另外 4 个错误。

Error   1   error C2059: syntax error : 'string'    d:\c-sharp\c++ 
compiling\consoleapplication7\consoleapplication7\libavutil\rational.h 31 1
ConsoleApplication7

我该如何解决这个字符串错误?

4

1 回答 1

25

猜测一下,您是否包含来自 C 源文件的代码?

extern "C" {只有 C++ 需要(或理解)守卫。您可以从 C 文件中省略它们,应将它们包含在 C++ 文件中,并应 __cplusplus在头文件中使用 ifdef 保护它们。

#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <limits.h>
#include "attributes.h"
#ifdef __cplusplus
}
#endif
于 2013-04-23T12:42:01.193 回答