1

I've seen this, but none of the answers worked for VS2010. The constant's (or should I call it variable?) numerical value didn't get displayed

This line of code #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX is turning out to be true when I'm actually programming in windows. I need to see the value of OGRE_PLATFORM_WIN32 and OGRE_PLATFORM_LINUX during the build process itself. Could you help with how to go about it?

Community
  • 1
  • 1
Nav
  • 19,885
  • 27
  • 92
  • 135

2 Answers2

2

You can check the preprocessor output using:

  • /E - preprocess to stdout or
  • /P - preprocess to file or
  • /EP - preprocess to stdout without #line directives

options in visual studio

Alok Save
  • 202,538
  • 53
  • 430
  • 533
  • 1
    New to VS. Where in the project properties should I include the /E? I didn't see any place where I could enter it. – Nav Feb 24 '12 at 07:47
0

First, check the preprocessor defines in project options - active configuration and all configurations, and make sure the right things are defined.

If you are still having problems, try substituting this for your main method:

#include <iostream>

int main()
{
    #ifdef OGRE_PLATFORM_LINUX
    std::cout << "OGRE_PLATFORM_LINUX = " << OGRE_PLATFORM_LINUX << "\n";
    #else
    std::cout << "OGRE_PLATFORM_LINUX not defined.\n";
    #endif

    #ifdef OGRE_PLATFORM_WIN32
    std::cout << "OGRE_PLATFORM_WIN32 = " << OGRE_PLATFORM_WIN32 << "\n";
    #else
    std::cout << "OGRE_PLATFORM_WIN32 not defined.\n";
    #endif

    #ifdef OGRE_PLATFORM
    std::cout << "OGRE_PLATFORM = " << OGRE_PLATFORM << "\n";
    #else
    std::cout << "OGRE_PLATFORM not defined.\n";
    #endif

    return 0;
}

Also, did you create the project, was it created by some type of pre-make (CMake, automake, etc) system, did you download it from somewhere? If you didn't create it, somebody could have ported over some Linux code without checking their preprocessor options.

parkovski
  • 1,503
  • 10
  • 13
  • Thanks, but I can't use couts because the program isn't compiling yet. I want to output during the build process itself. I just found that the linux condition and the windows condition are both evaluating to true, because all those constants weren't defined yet. Something is wrong with the header inclusion process. My question still remains, as to how to output the values of these constants during build time? – Nav Feb 24 '12 at 06:50
  • Can you disable all the other files and just compile the code I gave you? That'll at least tell you if those options are right. – parkovski Feb 24 '12 at 21:25
  • The options are right. The question is how to display the numeric values contained in these macros during the build process itself? – Nav Feb 27 '12 at 07:45