Strange Unresolved External Problem

C

cmiddlebrook

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.
 
?

=?ISO-8859-1?Q?Stefan_N=E4we?=

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
 
D

Duane Hebert

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.
 
R

Richard Herring

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.
 
C

cmiddlebrook

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.
 
B

benben

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top