简体   繁体   English

C2059 语法错误“字符串”?

[英]C2059 syntax error 'string' ?

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

I added extern "C" { } Then i got the C2059 string error So i tried to use #endif , now i have another 4 errors.我添加了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

How can i fix this string error ?我该如何解决这个字符串错误?

At a guess, are you including this code from a C source file?猜测一下,您是否包含来自 C 源文件的此代码?

extern "C" { guards are only required (or understood) by C++. extern "C" {只有 C++ 需要(或理解)守卫。 You can omit them from a C file, should include them in a C++ file and should guard them with a __cplusplus ifdef in a header file.您可以从 C 文件中省略它们,应将它们包含在 C++ 文件中,并应在头文件中使用__cplusplus ifdef 保护它们。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM