Strange Unresolved External Problem

Discussion in 'C++' started by cmiddlebrook@btinternet.com, Dec 9, 2005.

  1. Guest

    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, 2005
    #1
    1. Advertising

  2. 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
     
    =?ISO-8859-1?Q?Stefan_N=E4we?=, Dec 9, 2005
    #2
    1. Advertising

  3. Duane Hebert Guest

    <> wrote in message
    news:...

    > 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.
     
    Duane Hebert, Dec 9, 2005
    #3
  4. In message <>,
    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
     
    Richard Herring, Dec 9, 2005
    #4
  5. Guest

    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, 2005
    #5
  6. benben Guest

    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
     
    benben, Dec 9, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Harrison
    Replies:
    0
    Views:
    1,079
    John Harrison
    Jul 20, 2003
  2. Izak Pretorius
    Replies:
    2
    Views:
    1,633
    Christopher
    Sep 14, 2003
  3. Rodolphe
    Replies:
    4
    Views:
    1,131
    Rodolphe
    Oct 3, 2003
  4. mp
    Replies:
    2
    Views:
    6,989
  5. Scott Allen
    Replies:
    8
    Views:
    11,055
    Scott Allen
    May 2, 2004
Loading...

Share This Page