Jump to content

  • Log In with Google      Sign In   
  • Create Account

vc 2008 intellisense calling my class function some thing else


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 ankhd   Members   -  Reputation: 1285

Like
0Likes
Like

Posted 24 January 2014 - 08:52 PM

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();



Sponsor:

#2 Nypyren   Crossbones+   -  Reputation: 4311

Like
3Likes
Like

Posted 24 January 2014 - 09:08 PM

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.

#3 ankhd   Members   -  Reputation: 1285

Like
0Likes
Like

Posted 25 January 2014 - 06:02 AM

thanks.

I'm going with renameing my function.



#4 cozzie   Members   -  Reputation: 1613

Like
1Likes
Like

Posted 25 January 2014 - 06:10 AM

I'd definately go for renaming too, will save a lot of headache if you try to find an issue in the future



#5 Aardvajk   Crossbones+   -  Reputation: 5982

Like
1Likes
Like

Posted 25 January 2014 - 08:12 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS