C++ Visual Studios 2015: #ifdef WIN32 not executing properly - c++

I am working on a large inherited C++ project and am trying to build it for the first time in VS 2015.I have all the build files, but my build is failing in visual studios because the conditional
#ifdef WIN32
.....
#else error
I am trying to run on windows, but the program always is falling back to the else statements logic.
I have everything possible installed for C++ in visual studios. Any help is greatly appreciated.

VS 2015 defines _WIN32, not WIN32. See this list of predefined macros.

Related

Visual Studio 2017 wont show c++ template/extansion

I am trying to use Microsoft visual studio IDE to run my c++ code, however, when I go to create a project, I do not see the option for a c++ project. I tried reinstalling the program to see if I could somehow install the package/extension however it just won't seem to come up.
The only templates that appear are in c# or f#.
If someone could please lead me into the right direction so that I can fix this, it would be great. Thank you.
I don't see any mention of C++ in the release notes.
According to this post on MSDN, there is no C++ support in the Mac version of Visual Studio. It contains links to instructions for using Visual Studio Code, as well as the option to install a VM running Windows.
Apparently Visual Studio Code supports C++ projects, since it can execute external tools. The Microsoft Visual C++ build tools are free for Windows, but I don't think there is a version for the Mac, so some other external compiler is necessary.

Create custom macro for C++ configuration in Visual Studio 2015

Background:
I found some answers for this question but they were focused more on earlier versions of visual studio for which it seems some things have changed. My issue is I've created a new build configuration called 'Profile' for which I would like to have a corresponding macro for similar to how visual studio's 'Debug' build has '_DEBUG' macro.
Question:
Where, in visual studio 2015, would I go about declaring a macro connected to my build configuration so I can use #if, #ifelse and other defines with the macro in my code? This relates to C++.

C++/CLI debug support under VS2015

Using Visual Studio, I have created Excel addin (.xll), where part of the code (the main project) is written in Native C++, but additional static library is written in C++/CLI (I need to use .NET dlls directly). Whole addin is compiled and started in Excel correctly - I can also debug it using Visual Studio 2013, BUT I cannot debug it using Visual Studio 2015. I can breakpoint in the Native C++ code, but when I try to Step Into C++/CLI function, I can see debugger behaves as doing Step Over. I am aware of this article:
https://blogs.msdn.microsoft.com/visualstudioalm/2013/10/16/switching-to-managed-compatibility-mode-in-visual-studio-2013/
but it seems like "Use Managed Compatibility Mode" doesn't work in 2015 (while it works in 2013). Is anyone aware how to make VS2015 work for me?
I had the same problem but it went away. I must have fiddled with a setting but never figured out specifically what it was.
In Tools>Options>Debugging I've got:
"Use Managed Compatibility Mode" : off
"Use Native Compatibility Mode" : on
Also in Project>Properties>Debugging I have:
Debugger Type: Mixed

OpenCV on Windows: can I build/run C++ projects WITHOUT using MS Visual Studio?

Question in the title. Ideally I'd like to make small C++ projects without MS Visual Studio. Right now I can't even get the code in samples/cpp/ to compile and run with basic g++.
For reference I've downloaded OpenCV 3.1 from here: https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.1.0/opencv-3.1.0.exe/download
I want nothing to do with Visual Studio, but from my search results all Windows OpenCV C++ projects seem to use it.

Problem in first program in driver programming using Visual Studio 2010

I am starting to learn this type of programming (driver programming) since a short while of the time.
I started by using the traditional way _> I mean I only used WDK to bulid and compiled driver and was working properly with simple method of projects but I faced small problems in advanced when i wanted to start to expand my program or make a little developed one.
So, I started using VS2010 in windows 7, I really faced a lot of problems because i do not have a background how can i used it as good as possible.
Finally, I reach to a good point, this point is say (If you want to start with driver programming in VS2010, 1- you should install WDK 2- install VS2010 3- Enter the paths of WDK headers dirctories into VS2010 Dirctories to be compatiple. 4- Start tor create new project and go on.
makefile project
Finally, I am really not sure, it is a correct way or not I am just beginner.
But I did like this and i found a good results
#include "wdm.h"
NTSTATUS DriverEntry( IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath )
{
DbgPrint("Hello World!");
return STATUS_SUCCESS;
}
And i got:
1>------ Build started: Project: 1, Configuration: Debug Win32 ------ 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(37,5): warning MSB8005: The property 'NMakeBuildCommandLine' doesn't exist. Skipping... ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
My question is:
Is this the correct way? How can I know this program is working properly?
Should I do something else to make my program work correctly in kernal mode?
Never build drivers in Visual Studio!
The only way to build driver is: open WDK Build Environment command prompt, cd to the driver project directory, and type "build".
You can use Visual Studio only as source code editor, but don't build driver with it! There are number of ways to do this, published in different programming sites, but professional driver developers strongly recommend to use only WDK build for this.
To open WDK build environment, click main Windows menu - Programs - Windows Driver Kits - WDK - Build Environments - select target OS - select build environment, according to target computer processor type. Checked build environment means Debug, free build environment means Release.
Look into DDKWizard. It tackles exactly the issue you're handling, and does it well.
You shouldn't use the compiler of Visual Studio. The WDK compiler may contain changes to the standard WinSDK or Visual Studio compiler.
On the other hand, using a build macro from the makefile step is a nice enough way to utilize Visual Studio for developing the driver, and building it with the build toolkit used by the WDK.
There is a nice batch file which calls the necessary build environment and redirects the error outputs to the Visual Studio output pane.
To clarify, I use a makefile project in visual studio where all source files are added, when building I call a batch file which calls in turn ddkbuild with the right parameters.