I installed LLVM for Windows, which includes Clang and a few other tools. It integrates with Visual Studio, and even lets me choose a "Platform Toolset" in the project properties. However, when I choose any of the toolsets that came with LLVM, __clang__ isn't defined, and _MSC_VER is defined instead. How do I make __clang__ defined when using LLVM and Clang in Visual Studio?
My Visual Studio version is the 2015 Preview (however I have also tested on 2013 with no success either), and my LLVM version is based off of SVN release 225473. I've tried LLVM-vs2012, LLVM-vs2013, and LLVM-vs2014 as the Platform Toolset without success.
Under Project Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions, add __clang__. Yes, this is just a workaround.
Related
Now, I would have not expected That, after 'upgrading' to a 'newer' version of the compiler.
In VS2017 std::filesystem was available through std::experimental::filesystem, Now after upgrading to VS2019 to my surprise it is not available at all. Not in std::experimental nor std::filesystem.
and YES, I've tried setting c++17 from project's settings even the 'latest draft' thing, any ideas?
For the sake of completeness and people searching this in the future.
To switch to C++17' std::filesystem in Visual Studio (regardless VS2019 or VS2017) you need to:
change the language standard in Project properties -> Configuration Properties -> C/C++ -> Language -> C++ Language Standard to at least ISO C++17 Standard (/std:c++17)
(Can also be found in Project properties -> Configuration Properties -> General -> C++ Language Standard)
change #include <experimental/filesystem> to #include <filesystem>
change in the source code all appearance of std::experimental::filesystem to std::filesystem
fix the possible differences between the experimental and final filesystem versions
For all those who struggle with porting their existing Visual Studio 2017 projects into Visual Studio 2019, having proper project settings and pulling their hair out to no avail:
in file VC\Tools\MSVC\14.26.28801\include\filesystem
there's:
#if !_HAS_CXX17
now for why this flag is not automatically being set when changing projects settings I have no idea.
Thus I've used:
#define _HAS_CXX17 1
#include <filesystem>
in my files as a workaround. Works fine.
Update: On another system, within project's file there was
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalOptions>/std:c++14 %(AdditionalOptions)</AdditionalOptions>
The latter line was resulting in problems (obviously). Switching higher-level project settings does not remove such optional settings (obviously).
I hit the same issue [include filesystem] with the 2019 version (Microsoft Visual Studio Community 2019 Version 16.6.0) in spite of C++17 language selection.
I had to explicitly change the platform and the Active Solution platform to x64 in the configuration window (though, I started with x64). With this, the error is gone.
You will have to update your Visual C++ redistributable if you haven't. Then under project properties > Configuration Properties > C++ Language Standard: Select C++17 or higher.
You could try setting it to that by default. See this:How to change default C++ language standard in Visual Studio 2019?
The correct solution to that is:
For Xcode:
go to project properties
under build Settings, scroll down to Apple Clang- Language- c++.
there you have to select c++ language dialect and set it to C++17[-std=c++17].
cheers
Singh
I have a VS 2010 C++/CLI project that I imported into VS 2015. Because it links against some VS 2010 C++ libraries that I don't control, I need it to be compiled with the VS 2010 compiler. When I imported the project to VS 2015, I told VS not to upgrade the project (don't remember the exact options, but the project now says "Project Name (Visual Studio 2010)" in Solution Explorer). In the project properties, the Platform Toolset is listed as "Visual Studio 2010 (v100)":
One of the libraries I'm using has a header with some ifdefs that show an error if _MSC_VER isn't one of the supported versions (Visual C++ 6.0-10.0). That error is being generated for this project, and I've determined that the _MSC_VER showing up during build in Intellisense is 1900 (the default for VS 2015).
How do I get the project to build with the 2010 version of the C++ compiler (_MSC_VER 1600)? Isn't that what the Platform Toolset option is supposed to control?
I misunderstood what was going on in Visual Studio. The build was actually working fine; the error being generated was coming from Intellisense. There's a known bug in Visual Studio where Intellisense doesn't properly reflect the _MSC_VER specified by the project's selected Platform Toolset. I'll leave the question up in case anyone else runs into this problem.
I have some code that compiles in Visual C++ 2013, but am told it doesn't build in VC++2010 (as it uses a subtle c++11ism).
Of course, the thing to do is for me to test with both compilers, but...
isn't there a way to turn off c++11 in visual C++ 2013 and have it only accept c++08, as I think gcc's -std=c++98 option does?
For this case, the only way is to change the Platform Toolset to Visual Studio 2010 (v100) in Project -> Properties -> General. Once you change it, you will run VC++2010 compiler under VS2013.
I'm writing a Ruby C Extension against Ruby libs that where compiled with Visual Studio 2010. (I cannot change this, or recompile the Ruby core I'm building against, because it's embedded in a third party application.)
My project started out in Visual Studio 2010, but I later started using Visual Studio 2013 without upgrading the project - so it's still using the VS2010 toolkit.
In the Ruby include headers that I need to use there is a check:
#if _MSC_VER != 1600
#error MSC version unmatch: _MSC_VER: 1600 is expected.
#endif
Now, I thought since I was using the VS2010 toolkit for my project this check would still pass in VS2013. And this is where I'm confused:
The solution builds and creates the .so file which works, there is no warnings or errors in Output, but I just discovered that the Error List displayed a warning. IntelliSense will display 1800 for _MSC_VER - yet it compiles.
1 IntelliSense: #error directive: MSC version unmatch: _MSC_VER: 1600 is expected. c:\Users\Thomas\Documents\subd\ThirdParty\include\ruby\win32\i386-mswin32_100\ruby\config.h 4
So what is going on here?
Isn't Visual Studio using the VS2010 compiler when my toolkit is set to v100? (Then I'd expect _MSC_VER to be 1600.)
Is the #warning directive not something that blocks the compiler?
Is it IntelliSense that isn't picking up the toolkit version and instead always assume _MSC_VER is 1800?
_MSC_VER is directly tied to a toolkit, not the IDE.
The buggy Intelisense also behaves the same in VS2012 (with Vs2010 toolkit)...
I wanted to use VS2010 and an IDE and using MSVC 2005 as a compiler, how can I do that?
Visual Studio 2010 includes the capability of multi-targeting C++ projects (native or managed) using the Platform Toolset option. The built-in support is for v100 (VS2010) and v90 (VS2008).
See: C++ Native Multi-Targeting which shows how to extend the feature to support v80 (VS2005).
See these special MSDN instructions for managed projects.
You can use a makefile project to compile anything non-normative. We do this to compile with mingw and cygwin, but it will work the same way for any compiler
http://msdn.microsoft.com/en-us/library/txcwa2xx.aspx