标签: undeclared-identifier

什么是"未声明的标识符"错误,如何解决?

什么是未声明的标识符错误?什么是常见原因以及如何解决它们?

示例错误文本:

  • 对于Visual Studio编译器: error C2065: 'cout' : undeclared identifier
  • 对于GCC编译器: 'cout' undeclared (first use in this function)

c++ compiler-errors declaration undeclared-identifier

46
推荐指数
4
解决办法
28万
查看次数

错误:'uint16_t'未声明?

我有代码

#include <emmintrin.h>
#include <stdio.h>

void print128_num(__m128i var)
{
    uint16_t *val = (uint16_t*) &var;
    printf("Numerical: %i %i %i %i %i %i %i %i \n",
           val[0], val[1], val[2], val[3], val[4], val[5],
           val[6], val[7]);
}
int main(void)
{
    __m128i a = _mm_set_epi32(4, 3, 2, 1);
    __m128i b = _mm_set_epi32(7, 6, 5, 4);
    __m128i c = _mm_add_epi32(a, b);

    print128_num(c);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我收到一个错误,其中uint16_t没有声明.我正在使用GCC和MINGW.

这是完整的错误.

||In function 'print128_num':|
|6|error: 'uint16_t' undeclared (first use in this function)|
|6|error: (Each undeclared identifier is reported …
Run Code Online (Sandbox Code Playgroud)

c gcc undeclared-identifier uint16

23
推荐指数
1
解决办法
4万
查看次数

使用未声明的标识符:ASIdentifierManager

我使用以下代码来显示用于admob测试应用程序的唯一标识符.

这是我的applicationDidFinishLaunching ...

// Print IDFA (from AdSupport Framework) for iOS 6 and UDID for iOS < 6.
if (NSClassFromString(@"ASIdentifierManager")) {
    NSLog(@"GoogleAdMobAdsSDK ID for testing: %@" ,
          [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]);
} else {
    NSLog(@"GoogleAdMobAdsSDK ID for testing: %@" ,
          [[UIDevice currentDevice] uniqueIdentifier]);
}
Run Code Online (Sandbox Code Playgroud)

构建'使用未声明的标识符:ASIdentifierManager'时出错

我链接了AdSupport框架,可以访问声明标识符管理器的文件,但它仍然无法识别?

我已经清理了build文件夹,重启了xCode相同的结果.

admob undeclared-identifier ios ios6

19
推荐指数
1
解决办法
2万
查看次数

实际上声明了"未声明的标识符"

我已经在变量中得到错误C2065s,我在类头文件中声明为公共数据成员,一个int和一个指向该int的指针.被标记为错误的代码行只有当我在函数中使用这些变量时 - 在类'构造函数中,它们才能正常运行.

我正在使用Visual Studio 2010 Express编写普通的C++(而不是Visual C++),这里是编译器错误日志的输出:

1>------ Build started: Project: Project 2, Configuration: Debug Win32 ------
1>  BaseClassWithPointer.cpp
1>d:\libraries\documents\school\advanced c++\project 2\project 2\baseclasswithpointer.cpp(27): error C2065: 'q' : undeclared identifier
1>d:\libraries\documents\school\advanced c++\project 2\project 2\baseclasswithpointer.cpp(27): error C2541: 'delete' : cannot delete objects that are not pointers
1>d:\libraries\documents\school\advanced c++\project 2\project 2\baseclasswithpointer.cpp(32): error C2065: 'num' : undeclared identifier
1>d:\libraries\documents\school\advanced c++\project 2\project 2\baseclasswithpointer.cpp(33): error C2065: 'q' : undeclared identifier
1>d:\libraries\documents\school\advanced c++\project 2\project 2\baseclasswithpointer.cpp(34): error C2065: 'q' : undeclared identifier
1>  Generating Code...
========== Build: …
Run Code Online (Sandbox Code Playgroud)

c++ undeclared-identifier

9
推荐指数
1
解决办法
2万
查看次数

错误:使用未声明的标识符“std”C++

我是 C++ 编码新手,我想制作一个简单的口袋妖怪游戏。

我在头文件中创建了一个类,并在单独的文件中定义函数.cpp

我还有一个主文件,我将在其中运行我的实际代码。

所以我std::string在函数文件中定义了一个函数,它说std是一个未声明的标识符。

这是我的每个文件:

函数定义:

#include "fns.hpp"
int Pokemon::getHP() {
  return hp;
}
int Pokemon::getAttack() {
  return attack;
}
int Pokemon::getDefense() {
  return defense;
}
int Pokemon::getSpecialAttack() {
  return specialAttack;
}
int Pokemon::getSpecialDefense() {
  return specialDefense;
}
int Pokemon::getSpeed() {
  return speed;
}
std::string Pokemon::getAttack1() {
  return attack1;
}
std::string Pokemon::getAttack2() {
  return attack2;
}
std::string Pokemon::getAttack3() {
  return attack3;
}
std::string Pokemon::getAttack4() {
  return attack4;
}
Pokemon::Pokemon(int qhp,int qdefense,int qattack,int …
Run Code Online (Sandbox Code Playgroud)

c++ std undeclared-identifier

9
推荐指数
1
解决办法
3万
查看次数

具有常量问题的预编译标头

我的项目中有一些常量文件"Constants.h",我将其包含在Prefix.pch文件中,以供项目中的所有类使用.它们只包含一堆#define语句.

我的类不识别这些常量(没有自动完成),Xcode每次使用时都会给出"未声明的标识符"错误.但是当我运行项目时,一切正常(设置为忽略错误).

有什么办法可以摆脱这些警告吗?#pragma在前缀文件中忽略它们还是什么?我尝试了很多选项,包括在构建设置中将"预编译前缀头"设置为NO.

有任何想法吗?

编辑:我已经尝试删除派生数据和清理/删除生成文件夹无济于事.

值得注意的是,我的项目中有3个目标,而该项目中有另一个项目.

此外,一些#imports导入普通类.就像UIFont和Analytics类的类别扩展一样.这会影响它吗?

xcode constants objective-c prefix undeclared-identifier

8
推荐指数
2
解决办法
2641
查看次数

如何检查变量是未定义还是未在 javascript 中声明?

我知道要查找 javascript 中是否未声明变量,我可以使用if (typeof variable === 'undefined'). 如果我将变量声明为 undefined ( var variable = undefined),则 if 语句仍返回 true。在 JavaScript 中,是否有可能找到未声明的变量和值为 undefined 的变量之间的区别?我知道它们很相似,但是这样做const variable = undefined然后variable = "something else"会抛出错误,所以它们一定是不同的。

const variable = undefined

if (typeof variable === 'undefined') {
  console.log('"variable" is undefined')
}

if (typeof undeclaredVariable === 'undefined') {
  console.log('"undeclaredVariable" is undefined')
}
Run Code Online (Sandbox Code Playgroud)

我不想使用 try catch 块,因为我希望能够基于此分配另一个常量。我想要一个这样的解决方案:const isVariableDeclared = variable === undeclared,除非undeclared在 javascript 中不存在。我知道我可以将 let 与 try catch 块一起使用,但我正在寻找更优雅的东西。

javascript undefined detection undeclared-identifier

8
推荐指数
1
解决办法
839
查看次数

错误:未声明的标识符:'OutputDebugString'

我在我的Delphi代码中使用OutputDebugString,但是我收到错误:

错误:未声明的标识符:'OutputDebugString'

这个OutputDebugString是哪个包?

delphi outputdebugstring undeclared-identifier

6
推荐指数
1
解决办法
6010
查看次数

在 C++ 项目中使用 Clang 时出现“使用未声明的标识符”错误

我在我的 C++ 项目中使用Clang作为语法检查器。它是通过 Emacs 中的 Flycheck 调用的,我收到了一个恼人的 use of undeclared identifier错误,下面的最小工作示例说明了该问题:

在文件中testnamepace.cpp

#include "testnamespace.hpp"

int main() {
    const unsigned DIM = 3;
    testnamespace::A<DIM> a;
    a.f();
    a.g();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在文件中testnamespace.hpp

#ifndef testnamespace_h
#define testnamespace_h

#include <iostream>

namespace testnamespace {
    // My code uses lots of templates so this MWE uses a class template
    template <unsigned DIM> class A;
}

template <unsigned DIM>
class testnamespace::A{
public:
    static const unsigned dim = DIM;

    A() {std::cout …
Run Code Online (Sandbox Code Playgroud)

c++ llvm clang undeclared-identifier flycheck

6
推荐指数
0
解决办法
7248
查看次数

glut库中缺少glutInitContextVersion()

我正在练习一些opengl代码,但是当我想强制opengl上下文通过glutInitContextVersion()使用某个版本的opengl时,它会失败编译过程并给出这样的信息: -

使用未声明的标识符'glutInitContextVersion'

我想解决这个问题,所以我保持我的代码尽可能简单

#include "File.h"
#include <GLUT/GLUT.h>
#include <OpenGL/OpenGL.h>

using namespace std;

int  main ()
{

    glutInitContextVersion(3,2);

    return 1;
}
Run Code Online (Sandbox Code Playgroud)

但是,我能够使用其他过剩函数,没有任何错误或警告消息

我正在使用OS X 10.9.1在Macbook air上运行Xcode 4.4.1

c++ opengl macos glut undeclared-identifier

5
推荐指数
3
解决办法
6685
查看次数