error C2059: syntax error : 'bad suffix on number' - visual-c++

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;

Related

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.

Nodejs mongojs install error

I'm having some problems installing mongojs via npm. Whenever I try to install it (on windows 8) I just get a page full of red errors. There's so many of them that I don't even know where to begin, heres a sample of them (this is maybe 1/10 of total errors):
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers\security_credentials.h(52): error C4430:
missing type specifier - int assumed. Note: C++ does not support default-int (
..\lib\win32\wrappers\security_credentials.cc) [C:\Users\Simon\AppData\Roaming\
npm\node_modules\mongojs\node_modules\mongodb\node_modules\kerberos\build\kerbe
ros.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers\security_credentials.h(47): error C2039:
'HasInstance' : is not a member of 'v8::Persistent<v8::FunctionTemplate,v8::No
nCopyablePersistentTraits<T>>' [C:\Users\Simon\AppData\Roaming\npm\node_modules
\mongojs\node_modules\mongodb\node_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers\security_credentials.h(52): error C2143:
syntax error : missing ',' before '&' (..\lib\win32\wrappers\security_credenti
als.cc) [C:\Users\Simon\AppData\Roaming\npm\node_modules\mongojs\node_modules\m
ongodb\node_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers\security_credentials.h(53): error C4430:
missing type specifier - int assumed. Note: C++ does not support default-int (
..\lib\win32\wrappers\security_credentials.cc) [C:\Users\Simon\AppData\Roaming\
npm\node_modules\mongojs\node_modules\mongodb\node_modules\kerberos\build\kerbe
ros.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(53): error C4430: mis
sing type specifier - int assumed. Note: C++ does not support default-int (..\l
ib\win32\kerberos.cc) [C:\Users\Simon\AppData\Roaming\npm\node_modules\mongojs\
node_modules\mongodb\node_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers\security_credentials.h(53): error C2143:
syntax error : missing ',' before '&' (..\lib\win32\wrappers\security_credenti
als.cc) [C:\Users\Simon\AppData\Roaming\npm\node_modules\mongojs\node_modules\m
ongodb\node_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(53): error C2143: syn
tax error : missing ',' before '&' (..\lib\win32\kerberos.cc) [C:\Users\Simon\A
ppData\Roaming\npm\node_modules\mongojs\node_modules\mongodb\node_modules\kerbe
ros\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(54): error C4430: mis
sing type specifier - int assumed. Note: C++ does not support default-int (..\l
ib\win32\kerberos.cc) [C:\Users\Simon\AppData\Roaming\npm\node_modules\mongojs\
node_modules\mongodb\node_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(54): error C2143: syn
tax error : missing ',' before '&' (..\lib\win32\kerberos.cc) [C:\Users\Simon\A
ppData\Roaming\npm\node_modules\mongojs\node_modules\mongodb\node_modules\kerbe
ros\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(56): error C4430: mis
sing type specifier - int assumed. Note: C++ does not support default-int (..\l
ib\win32\kerberos.cc) [C:\Users\Simon\AppData\Roaming\npm\node_modules\mongojs\
node_modules\mongodb\node_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(56): error C2143: syn
tax error : missing ',' before '&' (..\lib\win32\kerberos.cc) [C:\Users\Simon\A
ppData\Roaming\npm\node_modules\mongojs\node_modules\mongodb\node_modules\kerbe
ros\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers\security_credentials.h(60): error C4430:
missing type specifier - int assumed. Note: C++ does not support default-int (
..\lib\win32\wrappers\security_credentials.cc) [C:\Users\Simon\AppData\Roaming\
npm\node_modules\mongojs\node_modules\mongodb\node_modules\kerberos\build\kerbe
ros.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(57): error C4430: mis
sing type specifier - int assumed. Note: C++ does not support default-int (..\l
ib\win32\kerberos.cc) [C:\Users\Simon\AppData\Roaming\npm\node_modules\mongojs\
node_modules\mongodb\node_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers\security_credentials.h(60): error C2143:
syntax error : missing ',' before '&' (..\lib\win32\wrappers\security_credenti
als.cc) [C:\Users\Simon\AppData\Roaming\npm\node_modules\mongojs\node_modules\m
ongodb\node_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(57): error C2143: syn
tax error : missing ',' before '&' (..\lib\win32\kerberos.cc) [C:\Users\Simon\A
ppData\Roaming\npm\node_modules\mongojs\node_modules\mongodb\node_modules\kerbe
ros\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers/security_context.h(57): fatal error C100
3: error count exceeds 100; stopping compilation (..\lib\win32\kerberos.cc) [C:
\Users\Simon\AppData\Roaming\npm\node_modules\mongojs\node_modules\mongodb\node
_modules\kerberos\build\kerberos.vcxproj]
c:\users\simon\appdata\roaming\npm\node_modules\mongojs\node_modules\mongodb\no
de_modules\kerberos\lib\win32\wrappers\security_credentials.h(47): error C2819:
type 'v8::Persistent<v8::FunctionTemplate,v8::NonCopyablePersistentTraits<T>>'
does not have an overloaded member 'operator ->' [C:\Users\Simon\AppData\Roami
ng\npm\node_modules\mongojs\node_modules\mongodb\node_modules\kerberos\build\ke
rberos.vcxproj]
The same type of thing occurs when I try to install mongoose. mongodb native installed ok but had to install visual studio first to get that to work.
Can anyone explain what is going on here?
Not ideal, but I did a fresh reinstall of node and visual studio and things seem to work OK now

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++.

Undeclared Identifier: Probably a very simple fix

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.

cannot convert parameter 1 from 'ATL::CString' to 'const wchar_t *'

For this line of code:
int currentSnapshotHeight = _wtoi(ExecuteExternalProgram(L"current.png"));
I got this error:
Error 1 error C2664: '_wtoi' : cannot convert parameter 1 from 'ATL::CString' to 'const wchar_t *'
How to fix?
Maybe this will work?
int currentSnapshotHeight = _wtoi(ExecuteExternalProgram(_T("current.png")));
Also check if Unicode setting of project are set as expected.
Try this:
int currentSnapshotHeight = _wtoi((wchar_t*)ExecuteExternalProgram(L"current.png").GetBuffer());

Resources