I'm trying to build Qt 5.2.0 from source using Visual Studio 2012. It is failing while compiling the following file:
/qtdeclarative/src/qml/jsruntime/qv4value_p.h
With the following error:
191: error C2039: _isnan: is not a member of std
Line 191 contains the following:
return doubleValue() && !std::isnan(doubleValue());
According to cppreference, std::isnan should be defined in the header cmath, since C++11. The Qt header file does include this header. When I inspect cmath in Visual Studio, I cannot see a function named isnan.
Am I right in concluding that VS2012 is missing this C++11 function? At first I thought I might have to enable C++11 support somehow, but according to this answer C++11 support is enabled by default. Given that binary downloads for Qt are available for VS2010 and VS2012, clearly it is possible to build with the respective compilers. Is there something I am missing?
isnan was implemented in Visual Studio'sstandard library starting with Visual Studio 2013.
There's most likely some sort of define to tell it that you don't have std::isnan available.
Related
I'm trying to port some OpenGL ES code from windows to Android using the Android NDK. I'm using Visual Studio 2017 and C++. What I did so far, I created a cross platform gles project in VS and removed the ios data. I'm putting one code file after the other and try to fix any errors I can find.
The issue I have is that is seems that math.h functions can't be found.
Here's some information that might be relevant:
Platform toolset is clang 3.8
Target API Level is android-21
Language standard is c++11
I have added m; as an option to linker library dependencies
If i include math.h I get:
use of undeclared identifier 'sqrt' (and all the other math.h functions I'm using)
If i include cmath I get:
no member names 'acos' in the global namespace (and all the other cmath functions)
Path for files (as found by Visual Studio):
c:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\platforms\android-21\arch-x86\usr\include\math.h
c:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\include\cmath
If I remove all math calls, it compiles.
Has anyone managed to use cmath in this context? If so, do you have any tips or point to what am I doing wrong?
Thanks.
If you #include <cmath> The methods are in std namespace so you should use std::acos etc.
I have not found a fix to the questions, but creating a project from the native android template allows you to use cmath without error, but you do need to add m; in linker input.
I want to use std::experimental::optional, but MSVS 2013 tells me it can't find the header.
Why isn't it there?
Can I roll my own based on code elsewhere? The C++14 proposal maybe?
std::experimental::optional originates from the Boost.Optional library, and this implementation works well in Visual C++ 12.0 (though it differs a little). Reference single-header implementation, based on the N3793 proposal paper, can be found here.
The latest list of supported C++11/14/1z core and library features that are shipped with Visual Studio can be found from the Visual C++ Team blog, from this post in particular. A set of header files of the Standard Library implementation (and some extensions) from Microsoft can be viewed here.
I've found that this implementation compiles with MSVC2013. Note that only compiles, everything else isn't guaranteed.
https://github.com/mapbox/variant/blob/master/include/mapbox/optional.hpp
I was using this one for msvc2015 and it worked:
https://raw.githubusercontent.com/akrzemi1/Optional/master/optional.hpp
I have some C++ code that uses some version of Google's GTest framework. This code used to compile fine with Visual Studio 2015. I just upgraded to VS2017, and now I get a bunch of errors like this:
error C2039: 'tr1': is not a member of 'std'
error C3083: 'tr1': the symbol to the left of a '::' must be a type
Is some compiler option needed to use std::tr1 in VS2017?
One option is to re-enable TR1; do this by defining the macro _HAS_TR1_NAMESPACE, as briefly mentioned in this blog article. If you're using an MSBuild project then this is best done by way of your project's Preprocessor Definitions setting; or if you're using a precompiled header, by defining it at the top of said PCH.
A better option is to inform GTest that your compiler supports C++11 by defining the macro GTEST_LANG_CXX11 to 1 before including any GTest headers; then it will use std::tuple rather than std::tr1::tuple*. (GTest's C++11-detection logic is __cplusplus-oriented, which VC++ has not yet updated despite being mostly C++11 and C++14 compliant. I would say this is a bug in GTest since it supports VC++ elsewhere throughout the configuration logic.)
* Not to mention the other C++11 features, which is why this is by far the better option ;-]
Googletest release 1.8.1 fixes this issue (in combination with VS2017 15.8.5).
When i write source files in visual studio 2013 and attempt to use the same source files for visual studio 2008, the files have syntax errors. Is it possible for visual studio 2013 to mimic the way that visual studio 2008 compiles?
The language I'm using is C++.
Visual C++ in VS2013 allows c++ 11 compliant code but VS2008 does not, so any syntax you use which is new to the standard will not compile under VS2008. You can either remove the syntax or look into the c++ futures libraries in VS2008 to see if what you need is there, or maybe in boost.
http://msdn.microsoft.com/en-us/library/bb982198(v=vs.90).aspx
and
http://www.boost.org/
New versions of VS tend to do the following which will break compatibility with older versions.
Support new C++ standards
Increase conformance with existing standards
Deprecate/remove proprietary extensions and incorrect implementations
Generally speaking, ISO standard C++ is backward compatible (there will always be some exceptions), which means most of the older syntax will compile on newer standards. So you will likely have more success if you create the sources first in VS2008 and then "migrate" to VS2013 (rather than create it in VS2013 first which may have incompatible syntax with VS2008).
I want to use std::initializer_lists in Visual Studio 2012 like a guy in this example does. My operating system is Windows 8 x64.
Therefore I lately installed the Visual C++ Compiler November 2012 CTP and as mentioned by Microsoft, I changed the platform toolset of my project to use that new updated compiler.
But even after doing so, there is neither a std::initializer_list nor a <initializer_list> header available. But the linked website from Microsoft tells me (under the headline "Overview") that initializer lists would be available with that update. I restarted both the IDE and my PC. I am not sure if it could be caused by the fact that I am (sadly) using the German edition of Visual Studio and the compiler update is in English. What am I doing wrong?
Update: Trying to compile the line auto a = { 0 }; which is criticized by IntelliSense the compiler output shows 'Microsoft Visual C++ Compiler Nov 2012 CTP' is for testing purposes only. and then compiler crashes and a error window appears which reads Microsoft (R) C/C++ Compiler Driver has stopped working. Without any new syntax, everything compiles and works fine with the new compiler selected.
(I work for Microsoft and with Dinkumware to maintain VC's Standard Library implementation.)
[danijar]
I am not sure if it could be caused by the fact that I am (sadly) using the German edition of Visual Studio and the compiler update is in English.
Unfortunately, the English-only CTP does not support German VS.
The "compiler driver" cl.exe is what invokes the compiler front-end c1xx.dll, the compiler back-end c2.dll, and the linker link.exe. It is very unusual for the compiler driver to crash. I speculate that it's attempting to display one of the error messages that were added by the CTP, but since the CTP didn't update the German resources, the compiler driver can't load the error message and proceeds to crash.
Note that this is different from an Internal Compiler Error in the front-end or back-end, or a normal compiler error that happens to be incorrectly emitted. (Many ICEs and bogus errors have been fixed after the CTP was released.)
But even after doing so, there is neither a std::initializer_list nor a <initializer_list> header available.
The CTP installed <initializer_list> in a special location. (It was actually written by the compiler team.)
On the command line, the incantations to use the CTP and put <initializer_list> on the include path are (assuming default locations):
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
set PATH=C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP\bin;%PATH%
set INCLUDE=C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP\include;%INCLUDE%
Trying to compile the line auto a = { 0 }; which is criticized by IntelliSense
This was documented - Intellisense was not updated by the CTP, therefore it will not recognize any of the new features.
[rubenvb]
The C++ Standard Library was not updated with the compiler, leaving you without decent <tuple> and <intializer_list> (this includes the omission of the braced init list constructors for all standard containers)
You may be interested to learn that we've updated the standard library to fully support scoped enums and initializer lists. This includes all initializer_list overloads mandated by the current Working Paper (N3485), plus installing <initializer_list> in the usual location along with all other standard headers. (It is also Dinkumware's official copy, although the differences between it and the compiler team's "fake" version were mostly cosmetic.) This stuff will be available in the next public release, whenever and whatever that is. Our next task is to update the standard library with explicit conversion operators and variadic templates, replacing our brittle simulations.
As you have noticed, the November CTP is very limited in usability for at least two reasons:
The compiler has numerous crash-causing bugs, such as the one you discovered.
The C++ Standard Library was not updated with the compiler, leaving you without decent <tuple> and <intializer_list> (this includes the omission of the braced init list constructors for all standard containers)
Also: the linked example is very ugly code. If you want to use this feature, use a compiler like GCC or Clang that supports this syntax. They are both available for Windows. Hacking around a half-implemented language feature by writing extra code is just stupid.