gpt4 book ai didi

c++ - C2059 语法错误 'string' ?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:05:01 28 4
gpt4 key购买 nike

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

如何修复这个字符串错误?

最佳答案

猜测一下,您是否包含来自 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

关于c++ - C2059 语法错误 'string' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16169522/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com