Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Strange Unresolved External Problem

Reply
Thread Tools

Strange Unresolved External Problem

 
 
cmiddlebrook@btinternet.com
Guest
Posts: n/a
 
      12-09-2005
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.

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Stefan_N=E4we?=
Guest
Posts: n/a
 
      12-09-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
Duane Hebert
Guest
Posts: n/a
 
      12-09-2005

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.


 
Reply With Quote
 
Richard Herring
Guest
Posts: n/a
 
      12-09-2005
In message <(E-Mail Removed) .com>,
(E-Mail Removed) 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
 
Reply With Quote
 
cmiddlebrook@btinternet.com
Guest
Posts: n/a
 
      12-09-2005
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.

 
Reply With Quote
 
benben
Guest
Posts: n/a
 
      12-09-2005
(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unresolved external symbol/using an external dll Scott Allen C++ 8 05-02-2004 06:11 PM
Linking errors. - VC++ - Unresolved external Symbol mp C++ 2 12-12-2003 06:21 PM
"unresolved external symbol" error in MSVC++ 6.0 Rodolphe C++ 4 10-03-2003 09:44 AM
error LNK2001: unresolved external symbol _IID_IDirectDraw7 Izak Pretorius C++ 2 09-14-2003 11:18 AM
Re: unresolved external symbol error. Need help! John Harrison C++ 0 07-20-2003 07:18 PM



Advertisments