NoMangle in C++

WTF is NoMangle? It’s not in my C++ book and when I Google it just returns lots of code fragments that use it.

I suspect it has to do with name mangling.

I’ve done a lot of C++ work and I’ve never heard of it, but at least one google result shows it as a simple macro that prevents C++ name-mangling by defining stuff as extern “C”:



#ifdef __cplusplus
  #define NoMangle extern "C"
#else
  #define NoMangle
#endif

NoMangle int DLL_IMPORT_EXPORT mgcAltitude(void);


In other words, it’s nothing special. Just a preprocessor trick to prevent C++ name mangling of your symbols by marking them as C-style symbols. If you don’t understand this, let me know and I (or someone else) can elaborate.

Thanks to both of you, it’s clear now. The link includes this: “The mangling scheme was established by Microsoft”. Should have known.

I used to be a hot spit C programmer back in the day before all the new fangled C++, .net, Java stuff. Now I’m like those old Cobol programmers I used to laugh at when I started working 30+ years ago.

Obligatory Cobol joke. Did you hear about Object Oriented Cobol? It’s called “Add 1 to Cobol”.