Sign in to follow this  

vc 2008 intellisense calling my class function some thing else

This topic is 1453 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all.

 

I have this class say

class foo

{

public:

        objbasej* GetObject(){//do stuff}

};

 

But Intellisense keeps thinking it  #define GetObject GetObjectA which is in WinGDI.h

 

It compiles ok but should I rename my function, And should it be doing that anyway it should only be in my class scope only hey.

 

 

objbase = foo.GetObject();

Share this post


Link to post
Share on other sites
Ah yes. Welcome to Win32's #define hell.

You have a few options:

1. Put #undef GetObject somewhere after your windows headers get #included. This will remove that macro and stop your function from getting renamed.
2. Rename your method to something that isn't #defined.
3. Isolate your Win32 #includes so they only make a mess in a small portion of your code that's easier to handle.
4. Make your own personal copy of those Win32 header files and remove the #defines from them so they don't make a huge mess of things. You will need to move such edited headers into your project so that anyone who uses your code gets these changes as well. I wouldn't necessarily recommend this because it's quite a bit of work and probably against some Microsoft EULA somewhere. You will also need to remember to call the appropriate function depending on your multibyte/unicode setting.

Share this post


Link to post
Share on other sites

The reason it is compiling is that the preprocessor is renaming your member function GetObjectA as well. When this is called as a member of the object, it is distinguished from the Windows free function GetObjectA by the usual mechanism.

 

The *A stuff is where Windows has two versions of each method taking string data, one for ASCII and one for UNICODE. Its a nightmare of namespace pollution but has to be because the API is C.

 

I agree changing names to avoid nameclashes with the Windows defines is better. It's annoying though.

Share this post


Link to post
Share on other sites
Sign in to follow this