Compile errors in mshtml.h compiling with VS2008 - c++

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.

Related

Having issues with linking to boost library (C++ in Visual Studio 2013)

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

Include winnt.h in my project

I am doing a small personal project involving printing out info about a PE file.
I have read that most of the pe structure is already defined in winnt.h header.
Upon including the winnt.h, and compiling the project i get the following error:
#error : "No Target Architecture"
I tried putting a define x86, it might have fixed the architecture problem, but there are even more compilation problems.
For example:
1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(363): error C2146: syntax error : missing ';' before identifier 'WCHAR'
1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(363): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(367): error C2143: syntax error : missing ';' before '*'
1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(367): error C2040: 'PWSTR' : 'CONST' differs in levels of indirection from 'WCHAR *'
check Compiler->Enable Microsoft extensions in Project options or use -Ze flag if you're compiling from the command line.

Winbase.h doesn't support in creating DLL file

I would like to create a project use to call c++ method using c#. So, I need to create a dll file for all of my c++ function. But when i get an error in y sqlite source code such as "AreFileApisASNSI undeclared identifier". So, i import winbase.h which is part of the mingw-w64 runtime package to my visual studio 2012 express DLL project. After import the file, I get many errors such as below:-
error c4430: missing type specifier - int assumed. Note: C++ does not support default - int
error C2143: syntax error : missing ';' before '_stdcall'
error c1003 error count exceeds 100; stopping compilation
error c2061: syntax error: identifier ' WINBOOL'
error c2086: 'int_CRT_INLINE' : redefinition
error c2143: syntax error: missing ';' before ''
error C2146: syntax error : missing ';' before identifier 'LONGLONG'
error C2146: syntax error : missing ';' before identifier 'PVOID'
any solution for those error? please help!!
The documentation for the function has this header requirement:
WinBase.h (include Windows.h)
This is telling you that the function is declared in WinBase.h, but that you should include Windows.h which in turn will include WinBase.h. So, you need to change your include to
#include <Windows.h>
I also wonder why you are talking about mingw considering that your compiler is MSVC. That compiler ships with a comprehensive Windows SDK. Why would you be using an SDK from mingw?

Strange errors in Microsoft SDK using Shobjidl.h

I want to retrieve the folder of the current user document folder in cpp, so I use SHGetFolderPath and include Shobjidl.h.
As the result my code does not compile and the following output is generated:
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\shobjidl.h(8994): error C2143: syntax error : missing ')' before 'constant'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\shobjidl.h(8994): error C2143: syntax error : missing ';' before 'constant'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\shobjidl.h(8994): error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\shobjidl.h(8994): error C2238: unexpected token(s) preceding ';'
The code behind these errors is:
virtual HRESULT STDMETHODCALLTYPE GetInt32(
/* [in] */ __RPC__in REFPROPERTYKEY key,
/* [out] */ __RPC__out int *pi) = 0; // <- this line produces compile error
What's wrong? Thanks in advance.
I am using Win 7, VS2010 Express.
The header file you need to include for that function is Shlobj.h, according to the documentation, not Shobjidl.h. I'd guess that Shobjidl.h is likely an internal header file and not meant to be included directly -- it probably depends on other header files already being included before it, which would fix the errors you're seeing.

syntax error : missing ';' before identifier 'PVOID64' when compiling winnt.h

I've recently got the source-code on a application. When im trying to build the solution, I get an error in all parts where winnt.h is included. The error codes differs a bit, but they always point to these lines in winnt.h:
typedef void *PVOID;
typedef void * POINTER_64 PVOID64;
and
struct {
DWORD crc;
BYTE rgbReserved[14];
} CRC;
So, what could be the cause of this? winnt.h is a standard header and has not been modified. Does it has something to do with me using VS 2010, or me using 64-bit windows? or is it some sort of configuration which is needed?
EDIT:
Here's the exact error-codes:
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(290): error C2146: syntax error : missing ';' before identifier 'PVOID64'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(290): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C2146: syntax error : missing ';' before identifier 'Buffer'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11525): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11525): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11556): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11556): error C2238: unexpected token(s) preceding ';'
You need to include windows.h rather than winnt.h. When you include windows.h it will, in turn, include winnt.h. You need to do it this way for the necessary macros to be in place that are needed to compile winnt.h.
In this case, POINTER_64 is defined in BaseTsd.h like this:
#define POINTER_64 __ptr64
But if you include winnt.h before including windows.h then POINTER_64 is not defined.
If you are using DirectX SDK, try changing the VC++ Directories for include and lib to be searched last.
It looks like your configuration of the Windows SDK is invalid.
This error is caused by the fact that the compiler is unable to recognize the 'POINTER_64' statement.
You may workaround this problem by replacing 'POINTER_64' with '__ptr64'.
I had the same issue recently. Then I've reinstalled the latest version of the Windows SDK and this fixed the problem.
UPDATE
#David Heffernan, correctly points to the fact that one should include windows.h instead of winnt.h
Try to remove DirectX SDK if you have one.
Here bug is accepted:
http://connect.microsoft.com/VisualStudio/feedback/details/508204/vc10-0-errors-while-compiling-winnt-h
Corrected manually syntax in winnt.h :
typedef void * POINTER_64 PVOID64; => typedef void * POINTER_64, * PVOID64;
If you are using librdkafka, you will get this error whenever "Windows.h" included.
I fixed it by rename "librdkafka/include/basetsd.h" to a different name, or access
this library header via sub path!
I think the author of this library made this file to deal with OS platform compatibility. But with the same file name "basetsd.h" as Windows Core, it just confusing Visual Studio.