I just installed Visual Studio 2015 RC Pro because I wanted to use c++11's std::to_string but it still doesn't seem to be 11...
std::cout << _cplusplus << std::endl;
Gives me 199711.
Is VS 2015 RC not supposed to have 11? Or am I doing something wrong?
Help appreciated.
Edit: it seems it isn't extremely clear what I want, so here's more info:
I want to use to_string, a member of std in c++11 which turns an int (in this case) into a string.
std::to_string(5);
gives me an error: "std has no member to_string"
Include the header <string>
VS2015 still doesn't fully support C++11, so the __cplusplus macro will remain as 97.
Related
I have installed colmap via vcpkg and it's not showing up for me. It shows up on .\vcpkg list but not on Visual Studio 2019.
All of colmap's dependencies are showing up when I do #include "" and they also show up on #include <> along with many other libs, but no colmap can be found.
What can I do? Let me knowm if there's any other info I can give, I'm fairly new to C++ and Visual Studio, so there's only so much I know is important.
I was finally able to include colmap. I had not payed attention to the debugger version I was using. It was set to x86 and my colmap was compiled at x64, so it would never show up on my VS2019!
I have the following code which fails to compile with Visual Studio 2017 with error
Error C2027 use of undefined type 'A'
but is compiling fine in Visual Studio 2012 & Visual Studio 2015.
#include <iostream>
class A;
std::string s = typeid(A).name();
class A
{
public:
int a;
};
int main()
{
std::cout << "Hello World!\n";
}
Can anyone suggest what exactly is the problem with VS 2017 compilation and how to fix this?
Is there any rule changes between VS 2015 and VS 2017?
The errors I get from clang and gcc for this example are more clear:
typeid.cpp:5:17: error: 'typeid' of incomplete type 'A'
std::string s = typeid(A).name();
^
typeid.cpp:4:7: note: forward declaration of 'A'
class A;
class A is a forward declaration of the A type, so the full information about that type is not yet known. I suspect behavior of Visual Studio 2012 and 2015 would be considered non-standard. You need to move your string until after the definition class A {...}; so the compiler can see the type definition.
Visual Studio 2015 offers _isnan and std::isnan to check if a double is NaN.
Following VS's 'Go to Definition' does not end up in the same place for both functions and assembly output from a simple program that checks for NaN is not the same.
How is _isnan different to std::isnan? Which should I use when writing C++?
_isnan is from Global Name Space which uses #include <float.h>
std::isnan is from Standard Name Space which uses #include <cmath>
You can use any one of them with Visual Studio 2015. Doesn't matter.
Refer this for more on this
From private communication with James McNellis of Microsoft (posted with approval):
"They were integrated into the C Runtime at different points in time. _isnan was integrated some time ago along with a handful of other IEEE recommended functions; isnan was added later as part of the C99 additions.
If you find a case where either produces an incorrect result, please do file a bug at https://connect.microsoft.com/visualstudio/."
I conclude from this that _isnan and std::isnan should do the same thing.
I had some code that I developed on Ubuntu and now I am trying to compile it on Windows 7 (MS VS 2010).
vector<float> tmp;
....
tmp = {3.0,4.5,9.4};
This gives me syntax error
error C2143: syntax error : missing ';' before '{'
Is this because Visual studio doesn't support this feature ? or should I be enabling some switch in the properties. I have the "Platform Toolset" property set to "v100."
Thank you.
The C++0x features are enabled by default on the Visual Studio 2010 C++ compiler. It takes no extra switches for example to use lambdas, auto, etc ... If you're getting that error it's because in all likelyhood it's not supported.
EDIT
Based on this MSDN article, initializer lists are not one of the 6 supported features in 2010
http://msdn.microsoft.com/en-us/magazine/ee336130.aspx
the Visual C++ compiler in Visual Studio 2010 enables six C++0x core language features: lambda expressions, the auto keyword, rvalue references, static_assert, nullptr and decltype
Visual Studio 2010 doesn't support initializer lists.
Look here for the supported C++0x features in Visual Studio 2010
Visual Studio 2012 doesn't support them, too.
You can find he C++11 features that are implemented in Visual Studio 2012 / VS11 here and here.
The first implementation of initializer list is available in the Visual C++ Compiler November 2012 CTP.
The first real release of initializer lists will be in Visual Studio 2013.
Even if they were there, this code would not work because it assigns an initializer list, which is not yet a vector, to an existing object named 'tmp'. You can assign to vectors like this:
vector<int> tmp = vector<int> {...}; // calls constructor, initializes then assigns
or
std::initializer_list<int> iniList = {1,2,3,4,5,6};
but not
std::vector<int> tmp;
tmp = {...}; // calls assignment operator
By the way: the feature is still missing in VS2012.
I've recently heard about the CaptureStackBackTrace function by reading this post. I cannot find it in any of my Visual Studio 2005 header files however, and I'm guessing (from the MSDN URL which mentions VS.85) that this may only be a Visual Studio 2008 thing.
Is there a way, perhaps by manually finding the entry point in a system DLL somewhere, to get this function under Visual Studio 2005?
Remarks
The CaptureStackBackTrace function is
defined as the
RtlCaptureStackBackTrace function. For
more information, see Winbase.h and
Winnt.h.
I haven't updated my Windows SDK beyond whatever comes with Visual Studio 2005 but I have found this solution to work:
typedef USHORT (WINAPI *CaptureStackBackTraceType)(__in ULONG, __in ULONG, __out PVOID*, __out_opt PULONG);
CaptureStackBackTraceType func = (CaptureStackBackTraceType)(GetProcAddress(LoadLibrary("kernel32.dll"), "RtlCaptureStackBackTrace"));
// Then use 'func' as if it were CaptureStackBackTrace
Did you update your Windows SDK to the most recent version? Since this is a Windows API function, it should be included there.