I have a code that generates errors on my PC but does't on other PC.I have windows 7 installed and also installed the compatible SDK for windows 7.I have also included the VC directories (from Tools -> option-> vc Diretories) but still the code generates follwing errors.
error C2059: syntax error : 'constant'
error C2238: unexpected token(s) preceding ';'
error C2589: '(' : illegal token on right side of '::'
warning C4091: '' : ignored on left of 'const unsigned int' when no variable is declared
error C2143: syntax error : missing ';' before '::'
error C2059: syntax error : '::'
error C2059: syntax error : 'constant'
error C2238: unexpected token(s) preceding ';'
statement generating error are as following
static const unsigned int MAPVK_VK_TO_CHAR;
const unsigned int KeyLogger :: MAPVK_VK_TO_CHAR = 0x02;
Try selecting MAPVK_VK_TO_CHAR and hitting F12 to see if the symbol is declared elsewhere.
What's MAPVK_VK_TO_CHAR? I ask because the error might indicate that this is some macro.
Why do you make a plain identifier (not a macro) all caps, anyway? That's just begging for one of the thousands of macros in <windows.h> to trample over it. (Not that not making it all caps would prevent that, since <windows.h> sacrilegiously defines many mixed-case macros...)
Otherwise you would have to paste some minimal, compilable example showing the problem.
Related
I have been banging my head on this for a few days now. I tried downloading and compiling the latest boost 1.67.0, to include
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/process.hpp>
But I got the errors seen below when trying to compile (one thing I noticed about it is that the path has slashes going the wrong way in the error log and Im not sure how to fix that?
I tried compiling with standard cmd and also Visual Studio 2013 prompt (same result).
I then tried grabbing the precompiled version from boost site
boost_1_67_0-msvc-12.0-32.exe
And am still getting the same problem. The #include text is not underlined in the editor. And I have additional include directories pointing to:
C:\VisualStudioLibraries\boost_1_67_0
and Linker Additional Library Directories to
C:\VisualStudioLibraries\boost_1_67_0\stage\lib
Does anyone know how to resolve this? If I comment out the #include lines for boost the code compiles without any issues and program runs. My code doesnt use anything from boost yet, so the only boost related stuff in there are the 3 #include lines.
Errors are:
1> MyForm.cpp
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(65): error C3646: 'noexcept' : unknown override specifier
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(72): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(77): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(82): error C2440: '' : cannot convert from 'std::error_code' to 'boost::process::process_error'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(88): error C2440: '' : cannot convert from 'const std::error_code' to 'boost::process::process_error'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(94): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C2146: syntax error : missing ';' before identifier 'Char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C2146: syntax error : missing ';' before identifier 'null_char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(98): error C2144: syntax error : 'char' should be preceded by ';'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(98): error C2143: syntax error : missing ';' before '<'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(99): error C2143: syntax error : missing ';' before '{'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(99): error C2447: '{' : missing function header (old-style formal list?)
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C2146: syntax error : missing ';' before identifier 'Char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C2146: syntax error : missing ';' before identifier 'equal_sign'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Thank you all very much.
Well, Im sure this is not the answer most will want to hear, but after trying for over a week to get it to work the only thing that ended up working was to move on to Visual Studio 2017. Everything linked and compiled fine there. Perhaps there is an issue with my VS2013 install (but everything else works flawlessly on it).
I've downloaded a source code originally from a Code::Blocks project, in which it works absolutely fine compiling with MinGW and GCC.
I tried to load it in Visual Studio 2010 and set the includes/libraries accordingly, but I'm getting tons and tons of errors from within the standard library headers and others as well.
Mainly, they are errors like:
...\stdlib.h(314): error C2146: syntax error : missing ')' before identifier '__nptr'
...\stdlib.h(314): error C2061: syntax error : identifier '__nptr'
...\stdlib.h(314): error C2059: syntax error : ';'
...\stdlib.h(314): error C2059: syntax error : ','
...\stdlib.h(314): error C2059: syntax error : ')'
...\stdlib.h(315): error C2373: '__restrict__' : redefinition; different type modifiers
From code:
(314) strtod (const char* __restrict__ __nptr, char** __restrict__ __endptr);
(315) float __cdecl __MINGW_NOTHROW strtof (const char * __restrict__, char ** __restrict__);
And so on.
Must have screwed up big time to have such a massive amount of errors. I really have no idea where it went wrong though.
I am trying to compile a file which requires functions included from cmath. I do not believe my code itself to be at fault for causing this error, I suspect the configuration (it persists even with all of the non-include code commented), but have no idea what is going wrong. I am compiling on a Windows host, 64 bit. Other than adding the masm build configuration, I don't believe I've changed any compile settings to non-default, and the problem persists after disabling masm, and by setting the target configuration to 32 bit. Here is my generated output:
1>...\VStudio\VC\include\stdlib.h(467): error C2062: type 'long' unexpected
1>...\VStudio\VC\include\stdlib.h(467): error C2062: type 'long' unexpected
1>...\VStudio\VC\include\stdlib.h(467): error C2059: syntax error : ')'
1>...\VStudio\VC\include\stdlib.h(468): error C2143: syntax error : missing ';' before '{'
1>...\VStudio\VC\include\stdlib.h(468): error C2447: '{' : missing function header (old-style formal list?)
1>...\VStudio\VC\include\stdlib.h(471): error C2062: type '__int64' unexpected
1>...\VStudio\VC\include\stdlib.h(471): error C2062: type '__int64' unexpected
1>...\VStudio\VC\include\stdlib.h(471): error C2059: syntax error : ')'
1>...\VStudio\VC\include\stdlib.h(472): error C2143: syntax error : missing ';' before '{'
1>...\VStudio\VC\include\stdlib.h(472): error C2447: '{' : missing function header (old-style formal list?)
Any help would be greatly appreciated.
Edit:
I have found the troublesome line. Contrary to my expectation, the error does occur in the code, and is the fault of a line inherited from a previous version:
#define abs(a) ((a)<0? -(a):(a))
is responsible for my problems.
Next time, #include system headers before any of your own code. That way your macros can't mess with the system headers and lead you astray.
I have the following code which compiles without errors under Linux and Mac OS X. I now want to compile the code with Windows, but I get a lot of errors in the following code segment:
...
enum Type
{
UPDATE = 0, DELETE = 1
};
...
The error messages are these:
1>Request.hpp(48) : error C2143: syntax error : missing '}' before '('
1>Request.hpp(48) : error C2059: syntax error : '<L_TYPE_raw>'
1>Request.hpp(49) : error C2143: syntax error : missing ';' before '}'
1>Request.hpp(49) : error C2238: unexpected token(s) preceding ';'
What did I wrong, I am really confused, as this compiles without errors under Linux.
What can cause this errors?
The solution is quite easy, but one need to find out that DELETE is a Macro defined in the windows header.
I now added #undef DELETE and it works fine.
Type is an existing class. You need to change the name or specify that it's a literal.
You could try enum #Type to specify a literal, though you may need to prefix it with # elsewhere.
I'm in the process of moving one of our projects from VS6 to VS2008 and I've hit the following compile error with mshtml.h:
1>c:\program files\microsoft sdks\windows\v6.0a\include\mshtml.h(5272) : error C2143: syntax error : missing '}' before 'constant'
1>c:\program files\microsoft sdks\windows\v6.0a\include\mshtml.h(5275) : error C2143: syntax error : missing ';' before '}'
1>c:\program files\microsoft sdks\windows\v6.0a\include\mshtml.h(5275) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v6.0a\include\mshtml.h(28523) : error C2059: syntax error : '}'
1>c:\program files\microsoft sdks\windows\v6.0a\include\mshtml.h(28523) : error C2143: syntax error : missing ';' before '}'
1>c:\program files\microsoft sdks\windows\v6.0a\include\mshtml.h(28523) : error C2059: syntax error : '}'
Following the first error statement drops into this part of the mshtml.h code, pointing at the "True = 1" line:
EXTERN_C const GUID CLSID_CDocument;
EXTERN_C const GUID CLSID_CScriptlet;
typedef
enum _BoolValue
{ True = 1,
False = 0,
BoolValue_Max = 2147483647L
} BoolValue;
EXTERN_C const GUID CLSID_CPluginSite;
It looks like someone on expert-sexchange also came across this error but I'd rather not dignify that site with a "7 day free trial".
Any suggestions would be most welcome.
you might already have the symbols True & False defined, try
#undef True
#undef False
before including that file.
There is probably a #define changing something. Try running just the preprocessor on your .cpp and generating a .i file. The setting is in the project property pages.
EDIT: Also, you can get the answer from that other expert site by scrolling to the bottom of the page. They have to do that or Google will take them out of their indexes.
What other incodes do ou have in the currently compiling file? It may be that True has been defined by a macro already as 1. That would explain the error.
Thanks Guys. I found the right spot for those #undef's. I dropped them into the classes header file just before a #include <atlctl.h> that seemed to do the trick.
And thanks for the tip about that other expert site, I'll have to keep that in mind.