I'm relatively new at drivers with WDK and Visual Studio.
When I compile project in debug mode I get no warnings or errors and project compiles and runs fine. However, when I compile in release mode, compilation stops and I get an error stating that a warning was found and is being treated as an error. The details of this are dumped into a log file found at the project root dir.
What I would like to do is have the compiler in debug mode be as strict as the release mode compiler. Currently they are both at default. The release mode seems stricter. I am using VS 2010 and WDK. I'm not sure how to do this. It would be ideal if this setting was at the VS level and not at a per project level.
Also, It would be great if the warnings would show up in VS IDE instead of a log file.
Visual Studio has different configuration setting for debug and release mode.
Check whether do you have relevant configuration in project > project properties -> linker etc......
If there is mismatch between debug and release mode configuration then change it. This should work
--Ali Chachar
--Pakistan
There are code differences in the debug and release compilation that may lead to warnings unrelated to strictness of the compiler. Most noticeable is in the logs; in the release version KdPrint/KdPrintEx calls will be discarded. There is a good chance that some of your function input parameters are used for printing only and in case it's being omitted you'll end up with unused parameter warnings - this is the most frequent difference in debug vs. release compilations.
Even if you have a VS2010 solution, your driver isn't being compiled with the VS compiler but rather with the WDK compiler so VS settings are irrelevant here. You can migrate your solution to VS2012 which have driver support integrated.
Related
When I change from debug to release mode in Visual Studio and the code is being optimized after debugging in Release Mode, can I see what the optimized code looks like? Or it is already a binary code that is optimized so Visual Studio itself doesn't optimize the code by rewriting it in C++, so there is no any C++ code that is my code but already rewritten for optimalization.
The following works for both Debug and Release builds:
Set a breakpoint on the line(s) of interest.
Launch your program under the debugger (F5).
When your program breaks, right-click and select 'Go To Disassembly'.
But just to say, the code generated by the compiler in Release mode is not always easy to follow so be prepared for some surprises.
[Edit] As per #paddy's comment above, make sure that you compile your project with debugging information included, otherwise none of this will work properly:
Project properties -> C/C++ -> General -> Debug Information Format = Program Database (/Zi)
When I'm trying to compile my C++ project in Visual Studio, I keep getting the 2 following errors:
E1574: Static assertion failed with "Windows headers require the default
packing option. Changing this can lead to memory corruption. This diagnostic
can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined."
and
C2338: Windows headers require the default packing option. Changing this can
lead to memory corruption. This diagnostic can be disabled by building with
WINDOWS_IGNORE_PACKING_MISMATCH defined.
I think the issue has to be something in my Visual Studio settings, cause the project compiles fine on my other PC, and I just installed Visual Studio on this PC.
From doing some searches look like the issue stems from a mismatch of Windows packages, however when installing Visual Studio I tried to install all the C++ and Windows 10 modules I saw.
Also, I'm only including windows.h in order to use ShellExecute(), so if there's a better way to use ShellExecute() I'm open to that. Thanks!
As 1201ProgramAlarm mentioned above, the solution was disabling the /Zp (structure packing) compiler option.
I am writing a graphical application using SDL2. I started the project in VS 2013 and it ran with about 30 fps. Now with the exact same code in VS 2015 I only get 8 - 10 fps.
To make sure it wasn't caused by moving the solution to a newer Version of the IDE I created a completely new project and only copied the source files. I even compiled the SDL libraries in VS 2015 but still much slower.
Can I do something to get better Performance or do I have to use VS 2013?
Are you comparing Debug or Release builds? Assuming you are comparing Release builds, the most likely explanation is differing compiler optimization settings between VS2013 and VS2015. Visual Studio has a fairly large number of compiler flags that can impact performance. Look at the property pages for your project, particularly at the options under Configuration Properties -> C/C++ -> Optimization and see if there are differences. Make sure you are comparing properties for the same configuration (Release vs. Debug).
If you find a Debug build is much slower, it is possible there are extra security / debug checks enabled in your VS2015 solution that are not enabled under VS2013. Compare the other settings under Configuration Properties -> C/C++ and see if you can identify any differences.
How can I disable C++ compiler optimizations temporarily ?
Often need to do this for release builds while debugging. The project settings do help but they need to be changed each time for each project.
For Visual Studio
I tried compiler options in environment variables but the priority is the rightmost conflicting option so Visual Studio overrides any values I set by the project settings.(For eg. /Od set by me in the environment is overridden to /O3 added by the project settings)
For Eclipse
Again modifying the global settings for each project seems to be the only way. Multiple select doesn't show the optimization setting so I am forced edit multiple projects one by one.
In both VS and Eclipse you can add new build configurations, e.g. an "Unoptimized release" which has all the debug checks in the code removed (via NDEBUG macro), but also has optimization disabled for better debugging experience. This takes a little time to setup, but then switching optimization off is as easy as switching between debug and release build.
I normally work with Qt Creator for my C++ needs. When an assertion in my program fails, it can show me which assertion failed. In Visual Studio, I only see this:
I can click Retry to jump into the application, but it doesn't tell me which assertion failed. Even for a simple assert(false) Visual Studio tries to show me the source code for msvcr100d.dll, which isn't available.
How can I find out which assertion in my program failed? I really don't want to do a cumbersome manual search using a combination of breakpoints and std::couts for something that can be tracked down automatically.
Edit: Visual Studio did in fact generate a .PDB file for me, but it still isn't working. Although the debugger won't highlight the line with the failed assertion, I do see Assertion failed: false, file main.cpp, line 8 on the command line. Why can't it just show me the line and let me inspect the variables? I mean, all the information appears to be available...
All you should have to do is click "Retry" to break into the application's source code with the debugger. That will highlight the line containing the assertion that failed, so it's easy to see the culprit unless you like to cram multiple nested assertions onto a single line. And if you do, then you deserve all the pain that this might cause you.
The reason it's not working for you now is more than likely because you don't have the debugging symbols available from your application's current build. When you build an app with the compiler bundled with Visual Studio, depending on your project settings, it will generate a .PDB file, which contains the debug symbols. These are required to get useful information while debugging, such as what line produced the last failure.
Make sure that when you compile your application, you have it set to generate debug symbols. You should see a .PDB file in your /bin directory. As discussed here, the generation of debug symbols is orthogonal to whether optimizations are enabled (the configuration typically known as "Release").
Update: I just realized you're probably compiling/building the app in Qt Creator, and then trying to debug the binaries from Visual Studio. That's not going to work out well—if you don't compile using VS's tools, it's not going to generate debug symbols that the VS debugger can read.
I assume the problem would be the same in reverse: if you built with Visual Studio, then tried to debug with Qt Creator, it probably wouldn't be able to interpret the debugging symbols, either.
Therefore, I'd recommend sticking with a single toolset for building. It doesn't matter which IDE you use, but you'll need to compile/build with the same tools. You can configure either Qt Creator or Visual Studio to use the compiler and linker bundled with the other. Typically Qt Creator comes with a Win32 port of GCC, but it's trivial to get it to build with Microsoft's toolset instead, which would allow you to use VS to debug your code.