News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

[solved] preprocessor not working (#ifdef WIN32)

Started by blah_HP, December 01, 2008, 07:02:23 PM

Previous topic - Next topic

blah_HP

Hello all
Apparently, C:B isnt handling preprocessor directives well (I do understand these should be the compilers fault but oh well, it works on MSVC).

Im using MS VC9 compiler, and the following code fails to compile:


#include "XEngine/GLPrerrequisites.h"

#ifdef WIN32
#include <windows.h>
#else //LINUX
#include <GL/glx.h>
#include <GL/glxext.h>
extern "C" {
extern void (*glXGetProcAddressARB(const GLubyte *procName))( void );
};
#endif

namespace XEngine
{

void* getProcAddress(const char *procname)
{
#ifdef WIN32
  return (void*)wglGetProcAddress((const char*)procname);
#else //LINUX
  return (void*)glXGetProcAddressARB((const GLubyte*)procname);
#endif
}

}


When I try to compile, it complains that the glx.h header cant be found. Well Im using windows, and that header's a linux header, and as you all can see in the code its not supposed to be added! Am I missing something? MSVC compiles this just fine.

Thanks in advance.

MortenMacFly

Quote from: blah_HP on December 01, 2008, 07:02:23 PM
Apparently, C:B isnt handling preprocessor directives well
First of all: This is a compiler issue. C::B does not handle any pre-processors at all /except for CC). C::B is just an IDE.
You don't tell what compiler you are using - sol I cannot tell what's exactly the problem is. But here is an advice: If you are using an environment like Cygwin, then WIN32 might indeed NOT be defined as this is a Linux/Unix emulation layer. Everything else would make no sense.

So... start again and tell us something about the environment you are using. At least I can assure you that the "bug" does not reside in C::B but in your project setup / compiler choice. So you are one step further anyways... ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Jenna

@Martin:
He wrote he use MS VC9

@blah_HP
you should look if you accidently undefine WIN32 at any place, or if you do a 64-bit build, or anything else that makes WIN32 undefined.

I don't use MS compilers, so I can not have a closer look into it.

MortenMacFly

Quote from: jens on December 02, 2008, 08:16:46 AM
@Martin:
He wrote he use MS VC9
Yes, but the he wrote:
Quote from: blah_HP on December 01, 2008, 07:02:23 PM
Am I missing something? MSVC compiles this just fine.
So this made me think he does not use the compiler but another one...?!
I am confused now.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

blah_HP

OK maybe i wasnt clear enough:

Im using the MSVC9 compiler inside C:B
plus, I can also successfuly build this project inside MSVC9 itself (compiler and IDE)
I know this error is a compiler error, what Im trying to find out is exacly what Moerten mentioned: theres something really weird with my project setup.

Please note that this project builds unmodified inside MSVC9, and thats the catch. Any suggestions?

thanks for the replies so far!

rcoll

Apparantely the MSVC9 IDE (not the compiler) is defining WIN32, and probably a whole lot more
defines that you don't see.

Go into the compiler setup, and uder "DEFINES" add in WIN32 and see if that helps.

Ringo

blah_HP

It worked, thanks Ringo. Problem solved :)
Im amazed at the fact theres not much info regarding this issue around, ive searched everywhere, sounds like im the only one using MS compiler with C:B!

MortenMacFly

Quote from: blah_HP on December 03, 2008, 05:37:42 PM
sounds like im the only one using MS compiler with C:B!
I can assure you: No. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]