C ++:语法错误C2061:意外的标识符(C++: Syntax error C2061: Unexpected identifier)

这行代码有什么问题?

bar foo(vector ftw);

它产生

error C2061: syntax error: identifier 'vector'

What's wrong with this line of code?

bar foo(vector ftw);

It produces

error C2061: syntax error: identifier 'vector'

原文:https://stackoverflow.com/questions/3026542

更新时间:2019-12-25 09:40

最满意答案

尝试使用std :: vector来代替。 另外,确保你

#include

try std::vector instead. Also, make sure you

#include

2010-06-11

相关问答

bool不是ANSI C中的数据类型。它是C语言版本中的数据类型, 只有包含 ,但Visual Studio不支持C99,只有C89(C99还添加_Bool数据) type,可以在不包含任何标题的情况下使用)。 我建议你用另一种类型的int替换bool ,或者使用typedef用int或unsigned char或其他东西来替换它。 bool is not a data type in ANSI C. It is a data type in the C99 version

...

你有一个循环包含依赖项。 Collision.h包括Player.h,反之亦然。 最简单的解决方案是从Player.h删除#include "Collision.h" ,因为Player声明中不需要Collision类。 除此之外,看起来Collision.h一些包含可以被前向声明替换: // forward declarations

class Player;

class Platform;

class Collision

{

public:

Collision(void);

~Col

...

正如我上面的评论所说,你的问题与递归包含有关。 你可以做以下两件事之一: 1)更改您的Simulator类,以便使用对DOCO的引用或指向DOCO的指针,从而forward declare DOCO。 2)更改您的DOCO标头以使用指向模拟器的指针或对模拟器的引用,然后只需转发声明Simulator 。 最简单的更改(如果代码中的那些注释仍然存在)是更改DOCO.h : #pragma once

#include

#include

#include

...

这样就不再没有答案了! 以下评论包括找到的答案。 上下文太少,你编译的例子没有问题吗? - notNullGothik 7月18日16:14 非我没有编译样本,因为当我尝试加载VS项目我有一个空白项目无论如何我找到了解决方案。 FreeBuffer也在photoshop的SDK中声明,所以我在包含WX之前添加了#undef FreeBuffer,现在可以使用了! 希望它能帮助其他人。 杰夫 - IonOne 7月19日11:55 Just so that this is no longer una

...

尝试使用std :: vector来代替。 另外,确保你 #include

try std::vector instead. Also, make sure you #include

错误在于您正在将C ++代码编译为C.将您的文件的名称更改为main.cpp。 The error is that you are compiling C++ code as C. Change the name of your file to main.cpp.

您尚未在“顶点”着色器中为“改变frag_color”指定类型。 我假设你的意思是“改变vec4 frag_color”。 You haven't specified a type for "varying frag_color" in the Vertex shader. I assume you meant "varying vec4 frag_color".

这不是Qt的错。 这是CPP Rest SDK。 它定义了一个宏 U ,它很好地替换为qtypetraits.h中的U模板参数。 当我在C ++预处理器定义中定义_TURN_OFF_PLATFORM_STRING时,错误消失。 It's not Qt's fault. It's the CPP Rest SDK. It defines a macro U, which is happily replaced for a U template parameter in qtypetraits.h.

...

我找到了两种方法来解决我的问题。 我之前已经定义了msxml和ISoftDistExt来解决模糊问题,所以我不得不像以下那样#undef: #undef __msxml_h__

#undef __ISoftDistExt_INTERFACE_DEFINED__

#include

#include

此外,您可以使用#import语句,如follownig #undef __msxml_h__

#undef __ISoftDistExt_INTERFACE_

...

正如在此交叉发布中所讨论的,此问题的根本原因是涉及surface和texture关键字的代码位于.h文件中,该文件最终包含在.cpp文件中 在VS CUDA项目中,默认情况下,.cpp文件由cl.exe(windows主机代码编译器)编译。 .cu文件由NVIDIA GPU编译器/驱动程序nvcc编译。 cl.exe无法理解surface或texture关键字,因此抛出了上述语法错误。 唯一的解决方案是安排您的项目,使这些构造只出现在或将被包含在将由nvcc处理的文件中,nvcc是理解surfac

...

Logo

一站式 AI 云服务平台

更多推荐