compiler linkage warning

This is a discussion on compiler linkage warning within the C++ Programming forums, part of the General Programming Boards category; I don't quite understand with respect to the documentations on linkage compatibility business as shown in the compiler message below: ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    222

    compiler linkage warning

    I don't quite understand with respect to the documentations on linkage compatibility business as shown in the compiler message below:
    Code:
    1>e:\test\installer\prninst.h(159) : warning C4190: 'ObtainPrinterDriverDirectory' has C-linkage specified, but returns UDT 'std::basic_string<_Elem,_Traits,_Ax>' which is incompatible with C
    1>        with
    1>        [
    1>            _Elem=wchar_t,
    1>            _Traits=std::char_traits<wchar_t>,
    1>            _Ax=std::allocator<wchar_t>
    1>        ]
    I found a prospective problem that's associated with this warning could be that I'm using a string object inside a user-defined struct. Is it legal in the language to declare a string inside a struct?

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    The function is marked as "C", but your are using C++ code inside it. That's why it warns you.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    53
    Quote Originally Posted by stanlvw View Post
    Is it legal in the language to declare a string inside a struct?
    Yes, that's fine. Elysia is right; what's probably goinig on is that your header contains
    Code:
    extern "C"
    yet the function is returning a C++ type.

    --
    Computer Programming: An Introduction for the Scientifically Inclined

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Server Help
    By lautarox in forum C Programming
    Replies: 146
    Last Post: 09-24-2008, 06:32 PM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 07:13 PM
  4. Compiler warning question
    By Thantos in forum C Programming
    Replies: 6
    Last Post: 12-05-2003, 04:39 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21