7

I saw questions similar to this for older versions of Visual Studio but not this latest version. I am following a course on Lynda.com and basically the instructor is trying to use C++ in a pure form that will look the same for students using a visual IDE on Mac. Anyway, the instructor sets up a Working project for teaching the language constructs and such. He right clicks on the project in Visual Studio and under C++ there is Pre-processor section.

I should note that he is using VS 2013 Community Edition. I have a more fully featured version of VS 2015. I don't see that option for defining pre-processor directives on a "project" basis. MS won't let me install 2 copies of VS 2015, but maybe it will let me install VS 2013.

Still, I hope my question makes enough sense as to what we are trying to accomplish, so that I can find the option in VS 2015 Enterprise. Thanks, Bruce

Bruce Whealton
  • 1,051
  • 2
  • 14
  • 25
  • What exactly you want to do? AFAIK you can't define pre-processor directives - they are hard coded in the preprocessor. Do you mean "enabling certain directives that are disabled by default"? Or do you mean "defining macros"? What exactly you want to "define" and why? – Андрей Беньковский Oct 28 '15 at 08:26
  • 2
    I seriously doubt the enterprise edition does not support something as basic as adding PP entries while the community version does? I can be wrong of course, but are you saying that if you right-click your project (it *is* a C++ project, right?), you do *not* have Properties->Configuration Properties->C/C++->Preprocessor ?? – stijn Oct 28 '15 at 08:44
  • Are we talking about simply #ifdef MY_VAR ? While used heavily, though not recommended. – Jack Andersen Oct 28 '15 at 09:11

2 Answers2

14

You would need to at least add a .cpp file to your Source Files folder in the the current project that you right will click. That should give you the option you are looking for in Visual Studio 2015.

  • 1
    That was the solution to my problem, hoping for this to get more visibility. Thanks a lot ! – Guillaume M Jul 23 '16 at 10:33
  • I am still trying to find this elusive "C/C++" group in the property page for 2017. The repository I am trying to build in the solution has the main project that only references the other parts, and has no cpp files itself. Coming from eclipse I knew how to make a new source folder, file, and add it to the build path, but I am not sure how to do it here. Simply making the 'filter' and a new cpp file inside does not show me the group. I still only see some basic ones and "VC++ Directories". – Pysis Oct 15 '17 at 05:37
7

Right click on your project. Select Properties. You should see the below menu where you can navigate to Configuration Properties > C/C++ > Preprocessor.

This is how I see it in my Visual Studio Enterprise 2015.

Is this what you're looking for?

enter image description here

ThisClark
  • 14,352
  • 10
  • 69
  • 100
  • Yes, that is what I am seeking. It was hard finding a project type, though, that would show the C/C++ section in the Properties. I tried several types of applications that one might want to use for just basically learning c++ and which would thus just generate a console application. Many of my choices when I created the project, there was no section in the Property Pages for C/C++ settings. The drop-down was just not there for c/c++. I would think that if one chose C++ application, you would have a section for C/C++ options. – Bruce Whealton Nov 14 '15 at 21:06
  • 1
    Where are `%(PreprocessorDefinitions)` coming from? – Andrew Savinykh Mar 31 '17 at 07:24
  • @AndrewSavinykh I have no idea. I only answered this question at the time because I happened to see it pop up in the queue while I was also trying to figure out how to do it myself. You should probably open a new question here on SO. – ThisClark Mar 31 '17 at 13:31