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
Related
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
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.
My question is similar to this: Error: "warning C4005: 'SWIGTEMPLATEDISAMBIGUATOR': macro redefinition"
I have a similar warning code (changing on 'char16_t'):
xkeycheck.h(179): warning C4005: 'char16_t': macro redefinition
Then:
xkeycheck.h(179): note: argomenti della riga di comando: vedere la precedente definizione
di 'char16_t'
(Translation: "note: arugments of the command line: look at the previous definition of 'char16_t')
But it keeps on giving this:
xkeycheck.h(250): fatal error C1189: #error: The C++ Standard Library forbids macroizing
keywords. Enable warning C4005 to find the forbidden macro.
Compiler: Visual Studio 2015
Support for char16_t and char32_t was added to Visual Studio 2015. This means you can no longer create symbols with these names, but then again you don't need them anymore as they already exist.
The solution is to remove the creation of the typedef or macro, or at least guard it when defined(MSC_VER) && _MSC_VER < 1900.
See MSDN:
char_16_t and char32_t You can no longer use char16_t or char32_t as aliases in a typedef, because these types are now treated as built-in. It was common for users and library authors to define char16_t and char32_t as aliases of uint16_t and uint32_t, respectively.
To update your code, remove the typedef declarations and rename any other identifiers that collide with these names.
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.
Hi I am trying to work with the rcpp. For this I want some cpp code which loads a dll by use of a lib-file (which has the same name as ). the code which I let run is:
cppFunction(includes=c("#include "windef.h","#include \"C:/data/Rdata/IHUAPI.H\" "), 'int functietom(int a){long serverhandle;int lRet;lRet = ihuConnect ( "historian1",NULL,NULL, &serverhandle ); return 5;}', verbose
= TRUE)
I get the following error:
undefined reference to `ihuConnect#16' collect2: ld returned 1 exit
status Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object
'C:/Users/user1663/AppData/Local/Temp/RtmpSW1Ki7/sourcecpp_1a04df63309/sourceCpp_26588.dll':
LoadLibrary failure:
the ihuConnect function is located in the ihuapi.lib and ihuape.dll files. In c++ in visual studio I add the lib file as added dependency and then I get rid of this error because I also sometimes get this error and then it was that I forgot to add the lib file in the compilation.
Thus My question is: how can I add this lib file as option in the compilation.
when I use dyn.load
("C:/data/Rdata/ihUAPI.dll")
and then check if it is loaded then he says yes
the problem is that getDLLRegisteredRoutines('ihUAPI', addNames = TRUE)
then it says:
data frame with 0 columns and 0 rows
so the dll seems not to contain the functions but it does when I use it from visual studio.
So please some help with lib-files and ddl-files
Tom Wambecq
You missed the Rcpp FAQ entry 2.9 'Can I use Rcpp with Visual Studio ?'.
And to kill all the suspense: No, you cannot.