I'm working on a new development in C++, using MS Visual Studio 2005. For this, I need to add several new projects to my solution. I always set my warning level to 4, and turn on "treat warnings as errors" (project -> properties -> c++ -> general).
Is there a way for me to tell Visual Studio that this is my default so I don't have to do it for each new project I create?
The only way, that I know, is to modify the wizard. This isn't as hard as it sounds.
Go to your Visual Studio directory. Open VC\VCWizards\1033 directory, and open the common.js file. Now, search for the function AddCommonConfig.
Now, to set the default warning level to 4, find the line "CLTool.WarningLevel = WarningLevel_3;" and change it to "CLTool.WarningLevel = WarningLevel_4;" (note: it is set twice for debug and release configurations, so make sure you change it for both.)
Now, to make it treat warnings as errors, add a line (for both configurations) "CLTool.WarnAsError = true;"
Note, however, that this will change these settings for all the default VC wizards (but you probably want that anyway.)
Related
These two trivial lines of code:
const bool equal = (HUGE_VALF == HUGE_VALF);
static_assert(equal == true, "Fatal error");
in a test program work perfectly (no warnings and no errors).
When I copy them in the main project, I get this error on the assert:
error C2057: expected constant expression
Here the equal object is a constant with value = true.
Those lines of code are in both cases inside functions.
The two projects have identical settings (C++11, Visual C++ 2013 compiler, Visual C++ 2019 IDE, /W4, no optimizations).
What could be the reason of this different behaviour from the compiler?
When a newer Visual Studio IDE (like VS 2019) loads an older project for the first time, it asks to retarget the project. If You have the old Visual Studio installed, You can reject this action. Then the compiler from the original VS will be used by the newer IDE.
After loading the solution, in the Solution Explorer next to the project name, You will have the Visual Studio which will be used to compile the project.
If the paranthesis is missing, that means the compiler and standard library from the current Visual Studio is been used.
As mentioned in the comments:
I have no parenthesis after the project name (if I am looking in the right place). However, I realised about the issue in the include file paths: Test Project: 14.24.28314\include\cmath; Main Project: Microsoft Visual Studio 12.0\VC\include\cmath, i.e. a much older version, that internally still relies on the C math.h header. So, same compiler (VS2013), different libraries...
This indicates that You have most probably retargeted the project or created a new project in VS 2019.
To make a project in VS 2019 make use of the older compiler, You need to got to the project Properties -> Configuration Properties -> General -> Platform Toolset and change it to the appropriate Visual Studio.
Also make sure that all configurations (Debug, Release,...) for all machine types (32bit, 64 bit) have this setting the same value.
Because the test project is using VS 2019 - it has all the required definitions - so it works.
So the issue is that most probably, VS 2013 standard library is not C++11 complete and does NOT have a definition for HUGE_VALF.
But it could contain a definition for HUGE_VAL
You know my question. Here is the longer version. Downloaded 2017RC, it took me a day to set it up to work with UCRT, CMake, Google test and all the goodies. Then I tried to associate the usual hpp, h, cpp extensions two ways:
Control panel -> Default Programs -> Set Default Programs, choose Visual Studio 2017RC and then -> Set Program Associations where all the possible extensions that can be handled by this program are listed. None of the usual C++ extensions are listed.
Right click on a .cpp file, Open with, visual studio 2017 RC doesn't show up in the apps list, hunt it down and click on it. A dialog box pops up saying that The program you have chosen cannot be associated with this file type.
FYI, currently all the c, C++ extensions are associated with Qt. Am I to think that RCs are not expected to have this feature? Or is it some other sub-program within VS, with which the association should be made? Thanks for your help
I had the same problem for Visual Studio 2015. The answer here is a good starting point:
https://superuser.com/questions/977271/windows-10-visual-studio-2015-xaml-file-association
Specifically, modifying "HKEY_CLASSES_ROOT.cpp". I changed the (Default) String value to VisualStudio.cs.14.0 and it now opens .cpp files in Visual Studio 2015.
You would have to use whatever version Microsoft has for Visual Studio 17. Take a look at an existing working file extension to see what it uses.
As usual, backup everything before messing around in the Windows registry.
For what it's worth, Microsoft appears to have fixed this bug, and will apparently be releasing the fix in the next release:
https://developercommunity.visualstudio.com/content/problem/3122/vc-file-association-not-correct.html
I am currently modifying on a open-source project to suit my own need, however, the project to be built (or compiler) requires me to add a /EHsc option to cl.exe
I am using Microsoft Visual Studio 2012 to work on the project. I have been searching long enough but I cannot find the solution still.
Is it possible to add a flag via MS Visual Studio 2012? Because I saw the output log displaying that compiler (cl.exe) compiled with various flag in this project such as /nologo /c /WX.
How can I add the options to cl.exe with this IDE?
Project working on : SumatraPDF
[Edit #1] After reading the first answer provided below, this is the screen I got, it doesn't seem there is an option to do so.
Update: From the screenshot you posted, it seems the SumatraPDF project is NMake-based.
Therefore, you will have to add /EHsc to the build command line, using the NMake property page described here, or edit the Makefile directly.
Original, misguided answer follows:
Per MSDN:
To set this compiler option in the Visual Studio development
environment
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Select the C/C++ folder.
Select the Code Generation property page.
Modify the Enable C++ Exceptions property.
Or, set Enable C++ Exceptions to No, and then on the Command Line
property page, in the Additional Options box, add the compiler option.
Background:
My team wants Visual Studio for development on an existing codebase, for its various tools, and that's what most developers are used to using. However, the existing build system (an internal flavor of Jam) is very entrenched, and for a variety of factors cannot be changed.
The idea:
Create a project for each component. I did this using a description generated by Jam of what files go into each library, and making that into a QT project file. I call qmake on this to generate Visual Studio projects with "qmake -tp vc".
Disable Visual Studio's build. I did this by changing the Type of each source file to "does not participate in build" (by changing each to )
Add a pre-build event that calls the Jam build.
Problem:
Now, when I try to build from Visual Studio, it works, in that it calls Jam.
However, I would expect Visual Studio to think the project is always up-to-date, considering it is not actually tracking any source files for compile. But it is always out-of-date, and must call the pre-build command before debugging (which attaches the debugger to the executable, and works just fine).
I used DebugView to see what was going on, and for many of my projects, I get the following in the log
[12900] Project '<my project's name>' is not up to date because 1 build inputs were missing.
[12900] devenv.exe Information: 0 :
[12900] up to date is missing: '<my project's location>\#ECHO'
I've searched high and low, but cannot find any reference to #echo as a file input to anything anywhere. Does anybody know, and/or is there a way to track down why it is looking for this?
Im using MS visual studio 2010 PRoofessional version , and in both languages I'm using (C++ and UnrealScript with Nfringe ) there seems to be no auto complete , also with the nfringe there is no auto indentation either .
I was wondering how to fix this?
Most probably you accidentally switched into low-impact IntelliSense mode by pressing
CTRL+ALT+SPACE Just hit CTRL+ALT+SPACE to go back to the IntelliSense mode.
Are you writing a totally unmanaged C++ dll? There is no intellisense support for CLI/C++ projects in VS 2010
I have actually problems with C++ and Intellisense since VC6...
We now use Whole Tomatoes "Visual Assist" and it repairs Intellisense. :-) This single feature is the money worth.
When you open the solution file, do you get a warning about being unable to open the IntelliSense database? If so, that's the reason—UnrealEngine intentionally has a directory with the same name as the IntelliSense database to prevent its creation (Visual Studio can't create a file if a directory of the same name already exists). The engine code base is so large that having IntelliSense enabled slows everything to a crawl when you're editing code.
I'm also using Unreal Engine, and I met the same problem before, the solution was set the dirs by myself in VS project setting.
Open the property window of ur game project(e.g UDKGame), navigate to "NMake", "Include Search Path", and fill the needed header search path there.
You may copy the path list from the output of UnrealBuildTool.
The values u set here is only used by Visual Studio's IntelliSense, so there's no need to worry about build error.
This only works for C++, I'm not sure what's wrong with Unreal Script. I just updated to Visual Studio 2010 and has not installed the new nFringe.
Hope this answer is not too late