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

Thread: Question on name mangling?

  1. #1
    Join Date
    Dec 2010
    Posts
    644

    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 12th, 2013 at 12:28 AM.

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

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center