I am using Visual studio version 14.0.25431.01 Update 3. While upgrading an existing project in C++ from VS2k13 to VS2k15, I am getting the following build errors in xlocnum file placed at C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum.
Error C2912 explicit specialization 'void std::numpunct<char>::_Getvals(void)' is not a specialization of a function template Scripttest C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum 192
and
Error C2061 syntax error: identifier '_Elem2' InterPTest C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum 188.
Following code in xlocnum is throwing the error
template<_Elem2>
void _Getvals(_Elem2, const lconv *_Ptr, _Locinfo::_Cvtvec _Cvt)
{ // get values
_Dp = _MAKLOCCHR(_Elem2, _Ptr->decimal_point[0], _Cvt);
_Kseparator = _MAKLOCCHR(_Elem2, _Ptr->thousands_sep[0], _Cvt);
}
After explicitly typenameing template<_Elem2> with template, error resolves but the change has to be made in the windows file xlocnum itself, so its doesn't seem a valid solution. Please suggest a resolution for this issue, Thanks
Related
While compiling my project which seems extremely primitive
#include <iostream>
int main() {
std::cout << 1;
return 0;
}
I get many similar errors like
E0020 identifier "FLT_RADIX" is undefined smo c:\Program
Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.10.24930\include\limits 201
and
E0020 identifier "FLT_MIN" is undefined smo c:\Program Files
(x86)\Microsoft Visual
Studio\2017\Community\VC\Tools\MSVC\14.10.24930\include\limits 1084
All errors refer to the limits file. It might be a problem with references to C libs as was mentioned here
Visual studio 2015 gives me errors upon creating a simple test console program
but defining the path to the libs from Windows Kits explicitly didn't solve the problem.
I'm using Boost with a Qt project.
I added these lines to my .pro file.
INCLUDEPATH += C:/local/boost_1_62_0/
LIBS += "-LC:/local/boost_1_62_0/lib64-msvc-12.0/"
I'm linking against boost, as I use a the libICP library, that includes boost/multi_array and boost/array.
When I compile, I get a lot of errors :
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree:20: error: C2143: syntax error : missing ',' before '<'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree:21: error: C2518: keyword 'typename' illegal in base class list; ignored
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree:22: error: C2518: keyword 'typename' illegal in base class list; ignored
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree:132: error: C2065: '_Iterator_base0' : undeclared identifier
I suspect xtree is used by the implementation of multi_array or array, but I don't really know where to go from here.
Ok, so I found the solution (I was working on this issue since yesterday...)
In case someone else has a similar issue, it was just a case of unbalanced } at the end of the file ICP_Registration.h, that includes libICP.
Today I came across a really strange behavior of the msvc2013 compiler.
After nearly an hour, I found the causing bug.
Minimal example:
#include <iostream>
#include <vector>
int main(int argc, char *argv[])
{
float f1, f2;
std::swap<float>(f1, f2);
return 0;
}
When including std::vector, I get a bunch of very strange compiler errors with msvc2013! When compiling the code with mingw the code compiles fine, just as I would expect.
The errors:
main.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xlocale(341): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1892): error C2825: '_Alloc': must be a class or namespace when followed by '::'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1944): note: see reference to class template instantiation 'std::_Vb_iter_base<_Alloc>' being compiled
with
[
_Alloc=float
]
main.cpp(10): note: see reference to class template instantiation 'std::_Vb_reference<float>' being compiled
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1892): error C2510: '_Alloc': left of '::' must be a class/struct/union
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1892): error C2146: syntax error: missing '>' before identifier 'difference_type'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1898): error C2825: '_Alloc': must be a class or namespace when followed by '::'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1898): error C2510: '_Alloc': left of '::' must be a class/struct/union
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1898): error C3646: '_Sizet': unknown override specifier
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1898): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1906): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1913): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1920): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1937): error C3646: '_Myoff': unknown override specifier
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vector(1937): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
And yes - i do know this is now the msvc2015 compiler! I tested this one too, and these are the error messages from this compile
Is this a weird bug in msvc or why does and can this even happen?
This is a known issue in MSVC compilers. They argue that "calling swap() with explicit template arguments is not actually permitted by the Standard".
According to http://clang.llvm.org/get_started.html
I did the ALL_BUILD on Windows with Visual Studio 2010 and added the built stuff to my system path with $PATH=...ClangSourcBuildPath...\build\bin\Release
I now can compile the following file on the console with:
$> clang file_c.c
//file_c.c
#include <stdio.h>
int main()
{
printf("hello world\n");
return 0;
}
But if I do the same for the following file ($> clang file_cpp.cpp):
//file_cpp.cpp
#include <iostream>
int main()
{
std::cout << "Hello World!";
return 0;
}
I get the following errors:
In file included from file_cpp.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\iostream:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\istream:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\ostream:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\ios:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\streambuf:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xlocnum:13:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xiosbase:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xlocale:11:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\stdexcept:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xstring:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xmemory:15:
C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\utility:81:10:
error: missing 'typename' prior to dependent type name '_It::iterator_category' typedef _It::iterator_category iterator_category;
C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\utility:82:10:
error: missing 'typename' prior to dependent type name '_It::value_type' typedef _It::value_type value_type;
C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\utility:83:10:
error: missing 'typename' prior to dependent type name '_It::distance_type' typedef _It::distance_type distance_type;
C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\utility:224:32:
error: template parameter redefines default argument
template < class _E, class _Tr = char_traits< _E > >
...
I also tried:
$> clang++ file_cpp.cpp
$> clang -x c++ file_cpp.cpp
But I still get the same errors.
Can someone explain me what's wrong?
There are certain flags (I think it was -fms-extensions, not quite sure of the exact option) that are required to get clang to parse the VC++ headers.
The next problem you'll encounter is that the resulting executable cannot be linked. This is due to the fact that clang uses a different name mangling than MSVC, and will result in undefined references.
If you want to use Clang on Windows (which is currently possible with MinGW-w64), you can use my prebuilt packages, you'll need
Clang 3.2
GCC 4.6
Extracted to the same directory. GCC is in this case only used to call the linker. Clang can be used to compile everything.
There is currently no way to use clang for C++ with the Visual Studio headers+libs. C should work, but I haven't tested and there may be other ABI problems preventing this from working.
I am having some trouble converting an old project from VS6 to VS2005. At one place in the code it uses the type variant_t so it includes comdef.h for this purpose. comdef.h then includes comutil.h which generates these errors for me:
c:\program files\microsoft visual studio 8\vc\include\comutil.h(978) : error C2535: '_variant_t::_variant_t(int) throw()' : member function already defined or declared
c:\program files\microsoft visual studio 8\vc\include\comutil.h(970) : see declaration of '_variant_t::_variant_t'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1007) : error C2535: '_variant_t::operator int(void) const' : member function already defined or declared
c:\program files\microsoft visual studio 8\vc\include\comutil.h(998) : see declaration of '_variant_t::operator int'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1037) : error C2535: '_variant_t &_variant_t::operator =(int)' : member function already defined or declared
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1029) : see declaration of '_variant_t::operator ='
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1331) : error C2084: function '_variant_t::_variant_t(int) throw()' already has a body
c:\program files\microsoft visual studio 8\vc\include\comutil.h(970) : see previous definition of '{ctor}'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1588) : error C2084: function '_variant_t::operator int(void) const' already has a body
c:\program files\microsoft visual studio 8\vc\include\comutil.h(998) : see previous definition of '.H'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(2006) : error C2084: function '_variant_t &_variant_t::operator =(int)' already has a body
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1029) : see previous definition of '='
There is probably some configuration that is incorrect, some define missing or some include file I should have included but I can't seem to find the problem. Any pointers in the right direction is much appreciated
This looks like one of two things, an include order problem or as you stated something not getting defined but I am leaning towards the first one. You might want to check msdn and make sure there are no restrictions on when comutil.h can be included (I know this is an issue if you include winsock2.h before windows.h). There is also an option under C/C++ > Advanced to Show Includes (/showIncludes option from the command-line) which is generally helpful when trying to track issues like this down.
Does your own code do something like this:
#define long int