# Preventing name mangling in C++ applications?

**URL:** <https://forum.legato.io/t/preventing-name-mangling-in-c-applications/3551>\
**Category:** Uncategorized\
**Created:** [August 10, 2018, 9:59pm UTC](https://forum.legato.io/t/preventing-name-mangling-in-c-applications/3551 "2018-08-10T21:59:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktanikel](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@ktanikel](https://forum.legato.io/u/ktanikel)\
**Post date:** [August 10, 2018, 9:59pm UTC](https://forum.legato.io/t/preventing-name-mangling-in-c-applications/3551/1 "2018-08-10T21:59:18Z")

</div>

Hi,

My applications are written in C++ and while everything works as expected I’ve noticed some problems that are arising due to potential name mangling. Specifically, when I try to use the config tree API (le\_cfg.api), I get build errors

> error: ‘le\_cfg\_CreateReadTxn’ was not declared in this scope

I have the api in the requires section of my cdef

> requires:  
> {  
> api:  
> {  
> le\_cfg.api  
> }

It works when I declare the function le\_cfg\_CreateReadTxn in an extern “C” block leading me to believe that it’s due to name mangling. Is this by design or am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![andcor](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@andcor](https://forum.legato.io/u/andcor)\
**Post date:** [August 15, 2018, 1:06pm UTC](https://forum.legato.io/t/preventing-name-mangling-in-c-applications/3551/2 "2018-08-15T13:06:56Z")

</div>

Well, to my understanding the legato project is written in C and therefore you will have to add the legato function in a extern C block to be able to access them from C++ as the linker will otherwise try to find a C++ function with that given interface.  
So to answer your question, I think it is by design (or at least a consequence of the design choice to write the legato framework in C).

---

<div class="post-metadata">

**Author:** ![ktanikel](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@ktanikel](https://forum.legato.io/u/ktanikel)\
**Post date:** [August 15, 2018, 4:42pm UTC](https://forum.legato.io/t/preventing-name-mangling-in-c-applications/3551/3 "2018-08-15T16:42:28Z")

</div>

I believe legato headers already have extern C in them, so there is no need to do it again. My problem was that I was missing “interfaces.h” and I ended up making a mountain of a mole hill 🙂.
