0
votes

I have the same problem exposed here. I'm using Visual C++ Express 2010.

I tried declaring extern "C", and changing the options Project + Properties, Linker, Debugging, Generate Debug Info = No. My function names are mangled on every compilation.

After reading the answer of jjones I changed the calling convention from StdCall to Cdecl, and then my function names are correct in the compiled dll. But I need the StdCall because I'm using this dll from VB6 (Vb6 protests when using other calling convention). So, everytime I compile with StdCall calling convention, my function names get mangled again.

How can I avoid my function names from being mangled with StdCall calling convention? or Is there a way to call a function in a Dll with cdecl calling convention from VB6?

1
If the name looks like _function@16 then it's correct.Captain Obvlious
I get names with that format, but VB6 complains about the _ and @ characters :(Broken_Window

1 Answers

0
votes

After reading and reading I found out that (maybe) there's no way to avoid name mangling with StdCall calling convention.

I wanted to call my functions from VB6, so here's a workaround that actually works: Declaring the functions with alias:

Declare Function prettyname Lib "mydll.dll" Alias "_prettyname@16" () As Integer

Of course, it is better to use extern "C", so the names don't get horribly mangled.