CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    907

    Question on name mangling?

    How come sometimes I don't use declarations like extern "C", the Visual C++ compiler doesn't complain about a C++ method calling a C function? Is it because of variant compilers? because I've got name mangling problem when using mingw64 on the same set of source code.
    Thanks
    Jack
    Last edited by lucky6969b; July 11th, 2013 at 11:28 PM.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Question on name mangling?

    Quote Originally Posted by lucky6969b View Post
    How come sometimes I don't use declarations like extern "C", the Visual C++ compiler doesn't complain about a C++ method calling a C function?
    Maybe because the function is a C++ function that you're calling, and not a 'C' function?

    If you don't use extern "C", the function will be regarded as a C++ function, regardless of how "C-ish" the function looks internally. So why should the compiler complain? Not using extern "C" means that the function can be overloaded, thus some name mangling scheme is used by the compiler to allow the linker to disambiguate functions that share the same name but have a different signature.

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured