Thread: Unsupported Unicode ADDRINFO stuff

  1. #1
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    New York

    Unsupported Unicode ADDRINFO stuff

    I have a little compatibility problem with MINGW that I'd like to resolve. I am trying to resolve a hostname, and am using the getaddrinfo/freeaddrinfo family of functions. In the Platform SDK, it has a big family of declarations that include a ANSI/Unicode 'aliii' (aliases) for:

    GetAddrInfo: getaddrinfo/GetAddrInfoW
    FreeAddrInfo: freeaddrinfo/FreeAddrInfoW
    ADDRINFOT: addrinfo/addrinfoW

    However, MINGW only defines ANSI versions. So, I try to compile an application under the mingw system, and it fails saying ADDRINFOT is undefined. I use the PSDK ws2tcpip.h, and I get errors regarding some inline asm that doesn't work with g++, and realize that it doesn't matter because the libraries wouldn't work.

    So, purely for fun, I try to add the declarations in the MINGW header, and then just get linker errors for GetAddrInfoW/FreeAddrInfoW. Surely, the ws2_32 dll is a system one that implements both the ANSI and Unicode functions. Are they just unsupported in other ways? There aren't way's to add entries to the mingw import libraries are there?

    Is there a feasable workaround for this issue?

  2. #2
    Registered User
    Join Date
    May 2003
    You can explicity link the DLL without using an import library at all. The import library hides many DLL implementation issues behind the scenes, but there's no reason you can't do them manually.

    There are a lot of examples on the web of code that loads a DLL like this, as it's a problem that can come up in many areas. For example, when designing a program that allows plugins, you can't link to an import library for a DLL that doesn't exist yet. Further, if you use an import library and the DLL fails to load, there is no chance to gracefully recover, as your main program hasn't even started yet.

    Here's the MSDN overview of explicit linking:
    Last edited by Cat; 01-23-2007 at 02:44 AM.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    New York
    Okay so, since this is a ws2_32 function, should I just make all of my winsock use explicit and use GetProcAddress? That seems a little over the top to me. And my only solution seems like I would just make an import table somewhat like the PE loader does for me. This sounds awkward. Is it really what I want to do? Can I LoadLibrary a DLL that is already loaded?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem With Use of Unicode + Boost
    By Tonto in forum C++ Programming
    Replies: 0
    Last Post: 04-05-2007, 08:55 PM
  2. <string> to LPCSTR? Also, character encoding: UNICODE vs ?
    By Kurisu33 in forum C++ Programming
    Replies: 7
    Last Post: 10-09-2006, 12:48 AM
  3. Unicode file I/O
    By cunnus88 in forum C++ Programming
    Replies: 1
    Last Post: 05-05-2006, 01:07 AM
  4. Should I go to unicode?
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 10-13-2003, 11:37 AM
  5. Your stuff
    By smog890 in forum C Programming
    Replies: 6
    Last Post: 06-13-2002, 11:50 PM