Undeclared Identifier: Probably a very simple fix - visual-c++

Language: Visual C++, MFC
I'm attempting to make an array of pointers to CString variables that I have declared in my header file. In general, this is what I'm doing:
CString *variableArray[5] = {
&var1
, &var2
, &var3
, &var4
, &var5
};
For whatever reason, though, I keep getting the following error:
Error 1 error C2065: 'var1' : undeclared identifier 18
Error 2 error C2065: 'var2' : undeclared identifier 19
Error 3 error C2065: 'var3' : undeclared identifier 20
Error 4 error C2065: 'var4' : undeclared identifier 21
Error 5 error C2065: 'var5' : undeclared identifier 22
I'm not quite sure I'm getting this error. To me knowledge, this is the correct way to make an array of pointers. Any help would be awesome!
EDIT: Here are the declarations in the header file:
public:
CString var1;
CString var2;
CString var3;
CString var4;
CString var5;

Where do you create "variableArray"? If it's in a static method or outside the scope of the class, it would make sense why you're getting that error.

Related

error C2059: syntax error : 'bad suffix on number'

I am getting the following error when i try to assign the value to var.
unsigned long var= 0x7137449123ef65cdULL;
Is unsigned long long supported in vc++6?
Error:-
Error 1 error C2059: syntax error : 'bad suffix on number'
Solution
Based on the inputs from RogerRowland and Igor Tandetnik i resolved this issue.
Solution:
"unsigned __int64 var= 0x7137449123ef65cdi64;

Template argument with the name of a class in another namespace

In VC++ 2013 (and 2015 RC), I find that this results in compilation errors:
namespace namespace1
{
template<typename T>
class Bar
{};
}
namespace namespace2
{
template <unsigned Bar>
struct Foo
{
static const int value = (Bar < 1) ? 1 : 2;
};
}
Errors:
error C2059: syntax error : ')'
: see reference to class template instantiation 'namespace2::Foo<Bar>' being compiled
error C2143: syntax error : missing ')' before ';'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ';' before ')'
error C2059: syntax error : ')'
error C2238: unexpected token(s) preceding ';'
fatal error C1201: unable to continue after syntax error in class template definition
If I swap the order of the namespaces, I don't get an error.
Why is the compiler treating Bar as a type, when it's not qualified with the namespace?
Additionally, if I change the value initialisation to:
static const int value = (Bar > 1) ? 1 : 2;
I don't get an error either.
Encountered this while compiling Google Protocol Buffers, where this struct definition:
// Compile-time equivalent of VarintSize32().
template <unsigned Value>
struct StaticVarintSize32 {
static const int value =
(Value < (1 << 7))
? 1
: (Value < (1 << 14))
? 2
: (Value < (1 << 21))
? 3
: (Value < (1 << 28))
? 4
: 5;
};
won't compile due to a template class called Value existing in a namespace in our own codebase. I have worked around it for now by ensuring that the relevant Procotol Buffers header is included first, but it seems that this is a compiler bug?
Is there any other way to fix it, when I can't really change either Protocol Buffers code or the Value class?
Confirmed as a bug by Microsoft, will be fixed in 2015 RTM.

Socket.io with npm on windows 8.1

I wan't to install socket.io with npm 2.7.4, node 0.12.2 on windows 8.1 & get this error:
modules\engine.io-client\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(518): error C4430: missing type specifier - in
t assumed. Note: C++ does not support default-int [C:...\websocket\node_modules\socket.io\node_modules\so
cket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation.v
cxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(490): error C2065: 'request' : undeclared iden
tifier [C:...\websocket\no
de_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-clien
t\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(490): error C2228: left of '.data' must have c
lass/struct/union [C:...\w
ebsocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engi
ne.io-client\node_modules\ws\build\validation.vcxproj]
type is ''unknown-type''
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(529): error C2039: 'NewSymbol' : is not a memb
er of 'v8::String' [C:...\
websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\eng
ine.io-client\node_modules\ws\build\validation.vcxproj]
C:....node-gyp\0.12.0\deps\v8\include\v8.h(1599) : see decl
aration of 'v8::String'
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(529): error C3861: 'NewSymbol': identifier not
found [C:...\websocket\no
de_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-clien
t\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(536): error C2039: 'NewSymbol' : is not a memb
er of 'v8::String' [C:...\
websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\eng
ine.io-client\node_modules\ws\build\validation.vcxproj]
C:\Users....node-gyp\0.12.0\deps\v8\include\v8.h(1599) : see decl
aration of 'v8::String'
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(536): error C2228: left of '.As' must have cla
ss/struct/union [C:...\web
socket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine
.io-client\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(536): error C2059: syntax error : ')' [C:...\websocket\node_modules\sock
et.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\
ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(549): error C2039: 'New' : is not a member of
'v8::String' [C:...\websoc
ket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io
-client\node_modules\ws\build\validation.vcxproj]
C:....node-gyp\0.12.0\deps\v8\include\v8.h(1599) : see decl
aration of 'v8::String'
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(550): error C2466: cannot allocate an array of
constant size 0 [C:...\we
bsocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engin
e.io-client\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(550): error C2440: 'initializing' : cannot con
vert from 'int' to 'v8::Local' [C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\n
ode_modules\engine.io-client\node_modules\ws\build\validation.vcxproj]
with
[
T=v8::Value
]
No constructor could take the source type, or constructor overload re
solution was ambiguous
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(549): error C3861: 'New': identifier not found
[C:...\websocket\node_mod
ules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node
_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(555): error C2065: 'uv_work_t' : undeclared id
entifier [C:...\websocket\
node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-cli
ent\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(555): error C2065: 'req' : undeclared identifi
er [C:...\websocket\node_m
odules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\no
de_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(555): error C2448: 'NanAsyncExecute' : functio
n-style initializer appears to be a function definition [C:\Users...\websocket\node_modules\socket.io\node_modu
les\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\valida
tion.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(560): error C2065: 'uv_work_t' : undeclared id
entifier [C:...\websocket\
node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-cli
ent\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(560): error C2065: 'req' : undeclared identifi
er [C:...\websocket\node_m
odules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\no
de_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(560): error C2448: 'NanAsyncExecuteComplete' :
function-style initializer appears to be a function definition [C:\Users...\websocket\node_modules\socket.io\n
ode_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\buil
d\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(570): error C2039: 'request' : is not a member
of 'NanAsyncWorker' [C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\e
ngine.io-client\node_modules\ws\build\validation.vcxproj]
C:...\websocket\
node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-c
lient\node_modules\ws\node_modules\nan\nan.h(487) : see declaration of 'NanAs
yncWorker'
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(571): error C2065: 'NanAsyncExecute' : undecla
red identifier [C:...\webs
ocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.
io-client\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(571): error C2065: 'uv_after_work_cb' : undecl
ared identifier [C:...\web
socket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine
.io-client\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(572): error C2146: syntax error : missing ')'
before identifier 'NanAsyncExecuteComplete' [C:\Users...\websocket\node_modules\socket.io\node_modules\socket.i
o-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxproj
]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(572): error C2059: syntax error : ')' [C:...\websocket\node_modules\sock
et.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\
ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(716): error C2661: 'v8::Local::New' : no ov
erloaded function takes 1 arguments [C:...\websocket\node_modules\socket.io\node_modules\socket.io-client
\node_modules\engine.io-client\node_modules\ws\build\validation.vcxproj]
with
[
T=v8::String
]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(769): error C2039: 'AsciiValue' : is not a mem
ber of 'v8::String' [C:...
\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\en
gine.io-client\node_modules\ws\build\validation.vcxproj]
C:....node-gyp\0.12.0\deps\v8\include\v8.h(1599) : see decl
aration of 'v8::String'
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(769): error C2065: 'AsciiValue' : undeclared i
dentifier [C:...\websocket
\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-cl
ient\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(769): error C2146: syntax error : missing ';'
before identifier 'value' [C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modu
les\engine.io-client\node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(769): error C3861: 'value': identifier not fou
nd [C:...\websocket\node_m
odules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\no
de_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(817): warning C4267: 'argument' : conversion f
rom 'size_t' to 'int', possible loss of data [C:\Users...\websocket\node_modules\socket.io\node_modules\socket.
io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxpro
j]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(829): warning C4267: 'argument' : conversion f
rom 'size_t' to 'int', possible loss of data [C:...\websocket\node_modules\socket.io\node_modules\socket.
io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxpro
j]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(832): error C2065: 'value' : undeclared identi
fier [C:...\websocket\node
_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\
node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(840): error C2065: 'value' : undeclared identi
fier [C:...\websocket\node
_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\
node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(840): error C2228: left of '.length' must have
class/struct/union [C:...
\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\en
gine.io-client\node_modules\ws\build\validation.vcxproj]
type is ''unknown-type''
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(858): warning C4267: 'argument' : conversion f
rom 'size_t' to 'int', possible loss of data [C:...\websocket\node_modules\socket.io\node_modules\socket.
io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxpro
j]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(873): error C2065: 'value' : undeclared identi
fier [C:...\websocket\node
_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\
node_modules\ws\build\validation.vcxproj]
C:...\websocket\node_modul
es\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m
odules\ws\node_modules\nan\nan.h(873): error C2228: left of '.length' must have
class/struct/union [C:...
\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\en
gine.io-client\node_modules\ws\build\validation.vcxproj]
type is ''unknown-type''
..\src\validation.cc(108): error C2248: 'v8::HandleScope::HandleScope' : cannot
access protected member declared in class 'v8::HandleScope' [C:...\websocket\node_modules\socket.io\node
_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\v
alidation.vcxproj]
C:....node-gyp\0.12.0\deps\v8\include\v8.h(816) : see decla
ration of 'v8::HandleScope::HandleScope'
C:....node-gyp\0.12.0\deps\v8\include\v8.h(800) : see decla
ration of 'v8::HandleScope'
..\src\validation.cc(109): error C2664: 'v8::FunctionTemplate::New' : cannot co
nvert parameter 1 from 'void (__cdecl *)(const v8::FunctionCallbackInfo &)'
to 'v8::Isolate *' [C:...\
websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\eng
ine.io-client\node_modules\ws\build\validation.vcxproj]
with
[
T=v8::Value
]
There is no context in which this conversion is possible
..\src\validation.cc(112): error C2039: 'NewSymbol' : is not a member of 'v8::S
tring' [C:...\websocket\no
de_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-clien
t\node_modules\ws\build\validation.vcxproj]
C:....node-gyp\0.12.0\deps\v8\include\v8.h(1599) : see decl
aration of 'v8::String'
..\src\validation.cc(112): error C3861: 'NewSymbol': identifier not found [C:...\websocket\node_modules\s
ocket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modul
es\ws\build\validation.vcxproj]
..\src\validation.cc(134): error C2660: 'v8::True' : function does not take 0 a
rguments [C:...\websocket\
node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-cli
ent\node_modules\ws\build\validation.vcxproj]
..\src\validation.cc(134): error C2660: 'v8::False' : function does not take 0
arguments [C:...\websocket
\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-cl
ient\node_modules\ws\build\validation.vcxproj]
socket.io#1.3.5 node_modules\socket.io
├── debug#2.1.0 (ms#0.6.2)
├── has-binary-data#0.1.3 (isarray#0.0.1)
├── socket.io-adapter#0.3.1 (object-keys#1.0.1, debug#1.0.2, socket.io-parser#2.
2.2)
├── socket.io-parser#2.2.4 (isarray#0.0.1, debug#0.7.4, component-emitter#1.1.2,
benchmark#1.0.0, json3#3.2.6)
├── engine.io#1.5.1 (base64id#0.1.0, debug#1.0.3, engine.io-parser#1.2.1, ws#0.5
.0)
└── socket.io-client#1.3.5 (to-array#0.1.3, indexof#0.0.1, component-bind#1.0.0,
debug#0.7.4, backo2#1.0.2, object-component#0.0.3, component-emitter#1.1.2, has
-binary#0.1.6, parseuri#0.0.2, engine.io-client#1.5.1)
See solution in comments
i had some help on github, you can check the temporary solution there https://github.com/Automattic/socket.io/issues/2072

No. of errors possible

Is it possible to get 21 errors for a 20 line program in Any language? Any platform. ? Sorry if this should not be asked. I m new to programming. My trainer asked me this question. Can someone help or explain? Thanks in advance.
C++:
trolo = lolo; //1 line
Errors:
error C2065: 'trolo' : undeclared identifier
error C2065: 'lolo' : undeclared identifier
C#:
al; cas; r; sb; ds; es; ew; qw; 2; 32; a; int a = 2.3;
1 line, exactly 21 errors.:D

how visual studio tell c++ and c?

As the title says,does the visual studio distinguish these two files by their suffix?.c or .cpp?
I also have another question.At first,I stated the program like this:
int main(int argc, char **argv)
{
LARGE_INTEGER TimeStart;
LARGE_INTEGER TimeEnd;
QueryPerformanceCounter(&TimeStart);
static double Freq;
static int getfreq;
double mu,om;
double *v;
int it,i,j;
....
}
but it brings out many problems:
1>sor2d.c(23): error C2143: syntax error : missing ';' before 'type'
1>sor2d.c(24): error C2143: syntax error : missing ';' before 'type'
1>sor2d.c(25): error C2143: syntax error : missing ';' before 'type'
1>sor2d.c(26): error C2143: syntax error : missing ';' before 'type'
23 ling points to "static double Freq;"
but if I put "QueryPerformanceCounter(&TimeStart);" after the data allocation,the compiler can succeed.Could someone tell me why this happened,was is just because of my carelessness of omitting something or ignorance...?
In C, all variables must be declared before calling any methods.
Visual Studio will, by default, compile .C files as C. You can override this.
In C89, you must declare all of your variables at the top of the code block. You may also initialize them to compile-time constants (literals, macros that expand to literals, the values of variables that have already been initialized, and any operations on the above that can be performed at compile time). You cannot intersperse other types of statements (like function calls) within these declarations.
This limitation was removed in C99 (which is not supported by Visual C++) and C++.

Resources