By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,388 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,388 IT Pros & Developers. It's quick & easy.

Strange Unresolved External Problem

P: n/a
Greetings all,

I have a class which contains a function with the following signature:

MC_SDLImage* LoadImage(const std::string& file, int id);

and I call this function in two places in my code. For one of the calls
I am getting an unresolved external but it refers to the function as
"LoadImageA", notice the capital A on the end. Usually I can fix linker
errors pretty quickly but this one stumped me. In the end I tried
something weird... I changed the name of my function to be LoadImageA.
Now the call that was failing compiled, and the other call failed so I
had to change it to call LoadImageA and not LoadImage.

So I have two places in my code that call this function, ine one place
it calls it LoadImage and somewhere else it calls it LoadImageA. I was
pretty sure this was going to crash horribly once I was able to execute
it but it all works! This is the most bizarre thing I have ever seen
and I'm not comfortable with it at all!

Can anyone shed any light on this mystery? Many Thanks,

Caroline M.

Dec 9 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
cm**********@btinternet.com wrote:
Greetings all,

I have a class which contains a function with the following signature:

MC_SDLImage* LoadImage(const std::string& file, int id);

and I call this function in two places in my code. For one of the calls
I am getting an unresolved external but it refers to the function as
"LoadImageA", notice the capital A on the end. Usually I can fix linker
errors pretty quickly but this one stumped me. In the end I tried
something weird... I changed the name of my function to be LoadImageA.
Now the call that was failing compiled, and the other call failed so I
had to change it to call LoadImageA and not LoadImage.

So I have two places in my code that call this function, ine one place
it calls it LoadImage and somewhere else it calls it LoadImageA. I was
pretty sure this was going to crash horribly once I was able to execute
it but it all works! This is the most bizarre thing I have ever seen
and I'm not comfortable with it at all!

Can anyone shed any light on this mystery? Many Thanks,

Caroline M.


Take a look at the preprocesses source code.

(Hint: #ifdef LoadImageA #undef LoadImageA #endif)

Stefan
--
Stefan Naewe
naewe.s_AT_atlas_DOT_de
Dec 9 '05 #2

P: n/a

<cm**********@btinternet.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
So I have two places in my code that call this function, ine one place
it calls it LoadImage and somewhere else it calls it LoadImageA. I was
pretty sure this was going to crash horribly once I was able to execute
it but it all works! This is the most bizarre thing I have ever seen
and I'm not comfortable with it at all!

Can anyone shed any light on this mystery? Many Thanks,


Sounds like you're using windows. Windows has some annoying
macros that rename functions based on whether you have unicode
enabled. IIRC it's done in windefs.h.
If LoadImage is your function rename it.
Dec 9 '05 #3

P: n/a
In message <11**********************@g47g2000cwa.googlegroups .com>,
cm**********@btinternet.com writes
Greetings all,

I have a class which contains a function with the following signature:

MC_SDLImage* LoadImage(const std::string& file, int id);

and I call this function in two places in my code. For one of the calls
I am getting an unresolved external but it refers to the function as
"LoadImageA", notice the capital A on the end. Usually I can fix linker
errors pretty quickly but this one stumped me. In the end I tried
something weird... I changed the name of my function to be LoadImageA.
Now the call that was failing compiled, and the other call failed so I
had to change it to call LoadImageA and not LoadImage.

So I have two places in my code that call this function, ine one place
it calls it LoadImage and somewhere else it calls it LoadImageA. I was
pretty sure this was going to crash horribly once I was able to execute
it but it all works! This is the most bizarre thing I have ever seen
and I'm not comfortable with it at all!

Can anyone shed any light on this mystery? Many Thanks,


Just a guess, but I suspect you are including, or failing to include,
some platform-dependent header which defines LoadImage() as a macro
(ugh, evil) mapping to either LoadImageA() or LoadImageW(), depending on
the setting of some other macro, to switch between normal and wide
character arguments.

--
Richard Herring
Dec 9 '05 #4

P: n/a
Ugh, yes you guys are right. I found the evil macro in winuser.h. I
renamed my function to Load_Image and all is well. Thanks all!

Caroline M.

Dec 9 '05 #5

P: n/a
cm**********@btinternet.com wrote:
Ugh, yes you guys are right. I found the evil macro in winuser.h. I
renamed my function to Load_Image and all is well. Thanks all!

Caroline M.


Very soon after i dealt with windows i decided i had enough of these
macro non-sense. So to end it all i use a different naming for ALL my
functions/classes. Perhaps you too can consider that as an option to
have an easier life?

Ben
Dec 9 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.