# NoMangle in C++

**URL:** https://boards.straightdope.com/t/nomangle-in-c/450212
**Category:** Factual Questions
**Created:** [May 22, 2008, 5:28am UTC](https://boards.straightdope.com/t/nomangle-in-c/450212 "2008-05-22T05:28:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![DanBlather](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DanBlather](https://boards.straightdope.com/u/DanBlather)
#### Post date: [May 22, 2008, 5:28am UTC](https://boards.straightdope.com/t/nomangle-in-c/450212/1 "2008-05-22T05:28:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)
#### Post date: [May 22, 2008, 5:57am UTC](https://boards.straightdope.com/t/nomangle-in-c/450212/2 "2008-05-22T05:57:21Z")

</div>

I suspect it has to do with [name mangling](http://en.wikipedia.org/wiki/Name_mangling).

---

<div class="post-metadata">

### Author: ![spinky](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@spinky](https://boards.straightdope.com/u/spinky)
#### Post date: [May 22, 2008, 5:57am UTC](https://boards.straightdope.com/t/nomangle-in-c/450212/3 "2008-05-22T05:57:32Z")

</div>

I’ve done a lot of C++ work and I’ve never heard of it, but at least [one google result](http://users.ece.gatech.edu/~hamblen/4006/projects/surveybot/source%20code/mgc.h) shows it as a simple macro that prevents C++ name-mangling by defining stuff as extern “C”:

```auto

#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.

---

<div class="post-metadata">

### Author: ![DanBlather](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DanBlather](https://boards.straightdope.com/u/DanBlather)
#### Post date: [May 22, 2008, 6:26am UTC](https://boards.straightdope.com/t/nomangle-in-c/450212/4 "2008-05-22T06:26:58Z")

</div>

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”.
