Error during compilation of the code using make file in VC++ - winapi

I am using below snippet in my code.
//from Vista WinNT.h
//
typedef struct _TOKEN_MANDATORY_LABEL {
SID_AND_ATTRIBUTES Label;
} TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL;
When I build this through VS2005 it give no error. But when I am building using make file i am getting below error in cmd:
Test.cpp(337) : error C2011: '_TOKEN_MANDATORY_LABEL' : 'struct' type redefinition
C:\Program Files\Microsoft SDKs\Windows\v6.1\include\winnt.h(7351) : see declaration of '_TOKEN_MANDATORY_LABEL'
I am using Opus software to use make file. Please let me know if I am missing something or needs to add some libs to overcome this error.

Related

I get errors for including vector

I'm trying to write a simple program to display shapes using 3dCoin
however when starting to debug the program it gives me 51 errors in cmath file in which I did not change anything in it since it is a standard file.
#include <Inventor/Win/SoWin.h>
#include <Inventor/Win/viewers/SoWinExaminerViewer.h>
#include <Inventor/nodes/SoSeparator.h>
#include <vector>// when I include vector it gives me the errors
int main(int, char ** argv) {
HWND window = SoWin::init("0.off");
if (window == NULL) exit(1);
SoSeparator * root = new SoSeparator;
root->ref();
SoWinExaminerViewer *viewer = new SoWinExaminerViewer(window);
viewer->setSize(SbVec2s(640, 480));
viewer->setSceneGraph(root);
viewer->show();
SoWin::show(window);
SoWin::mainLoop();
delete viewer;
root->unref();
return 0;
}
The type of errors I'm getting are:
Severity Code Description Project File Line Suppression State
Error C2589 '(': illegal token on right side of '::' project c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\cmath 19
Severity Code Description Project File Line Suppression State
Error C2440 'type cast': cannot convert from 'float' to 'unknown-type (__cdecl *)(float)' project c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\cmath 19
and many more.....
Can anyone help find the reason I have been trying to find a solution for a while but could not understand the reason behind such errors?
I've received exactly the same error with you. More than 30 lines of cmath and also int8_t type redefinition error. I've solved this problem by putting each of my header files above Inventors and then I've put #define HAVE_INT8_T above everything in my source files due to the int8_t type redefinition error. Then, compile error is gone.

Attempt to access private member in dynamic_bitset

I am using Visual Studio 2017 to build LucenePlusPlus which in turn uses boost/dynamic_bitset.
The following code in LucenePlusPlus
const uint64_t* BitSet::getBits() {
return bitSet.empty() ? NULL : static_cast<const uint64_t*>(&bitSet.m_bits[0]);
}
generates the following fatal compiler error:
1>g:\luceneplusplus\src\core\util\bitset.cpp(20): error C2248: 'boost::dynamic_bitset<uint64_t,std::allocator<Block>>::m_bits': cannot access private member declared in class 'boost::dynamic_bitset<uint64_t,std::allocator<Block>>'
1> with
1> [
1> Block=uint64_t
1> ]
Suggestions?
I have traced the code for my boost 1_75_0 and I see it has a define to conditionally reserve access to friends:
#if defined(BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS)
#define BOOST_DYNAMIC_BITSET_PRIVATE public
#else
#define BOOST_DYNAMIC_BITSET_PRIVATE private
#endif
So it looks like you should be able to add -DBOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS to the compiler defines to fix this.
In fact, my LucenePlusPlus tree already contains it in
include/config_h/Config.h.in line 107:
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
Previously ("rebuilt cmake buildsystem") this apparently
came from include/Config.h.cmake, where it was always present, unconditionally all the way since 2010:
What Can You Do?
Maybe you are not including the required headers that include the config? Also check any interfering precompiled header settings.
If you have boost/dynamic_bitset.hpp included BEFORE including LucenePlusPlus headers at any point you will run with the wrong config.
This is especially bad if you don't detect it because that would violate the ODR rule

C++/CLI & Inconsistent layout information in duplicated types (std._Tree_unchecked_const_iterator)

I have got an issue after using the Platform Toolset v141 in Visual Studio 2017 for Debug 64 bit compilation.
typedef std::map<int, msclr::gcroot<cli::array<short>^>> MapIntToManaged;
int main(array<System::String ^> ^args)
{
MapIntToManaged testMap;
for (auto &it : testMap) {}
return 0;
}
This results in the linker error
error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._Tree_unchecked_const_iterator< ?? :: ?? >): (0x02000048).
1>LINK : fatal error LNK1255: link failed because of metadata errors
I found a couple of workarounds to get rid of this error:
changing the Platform Toolset back to v140
using this syntax instead of the auto iterator:
for (MapIntToManaged::iterator it = testMap.begin(); it != testMap.end(); ++it) {}
changing the Runtime Library from Multi-threaded Debug DLL (/MDd) to Multi-threaed DLL (/MD) and use NDEBUG instead of _DEBUG as preprocessor define
using 32 bit instead of 64 bit
I'd like to understand this issue.
And I want to use the newest toolset, the new iterator syntax and the Debug runtime DLL.

Solve "LINK : fatal error LNK1561: the entry point must be defined"

I am working with Visual Studio Ultimate 2012.
If I run the code from Visual Studio it works properly. But if I take the ".exe" file that it generates at the Debug file it doesn't in another computer.
That is why I change the menu from "Debug" to "Release", but then it doesn't compile and shows the message: "LINK : fatal error LNK1561: the entry point must be defined"
What do I have to change at the configuration to create a ".exe" that works in any computer?
I have a main defined in the project as void main(array<String^>^ arg)
Seems the signature of the main function is wrong. The expected signature for the EntryPoint main function should have int return type in VS2012.
Please try changing signature of function to:
int main(array<String^>^ arg)
This may resolve your problem.

boost 1.58 xpressive::sregex outputs errors in debug mode

I encountered some problems when using boost::xpressive of boost1.58 on Visual C++ 2013.
My test program that using below code spills errors like below.
This error does not occur on Release mode.
Is this a boost's bug?
sregex reg = sregex::compile("\\");
Error:
e:\dev\vs2013projects\sandbox\sandbox\sandbox.cpp(35) : see reference
to function template instantiation
'boost::xpressive::basic_regex>>>
boost::xpressive::basic_regex>>>::compile(const
char
*,boost::xpressive::basic_regex>>>::flag_type)'
being compiled 1>
e:\dev\vs2013projects\sandbox\sandbox\sandbox.cpp(35) : see reference
to class template instantiation
'boost::xpressive::basic_regex>>>'
being compiled

Resources