4

Suppose my code have an internal function, which is not exported, not available for public in any other way (say, a thread function for CreateThread). If I compile my application with C++ Builder (using 10.4 Sydney with classic compiler) - then I can check (via .map file) that my function will lose its name and will be named something like _16386. It always starts with _ followed by some integer. Another example are names like C3304_3, D304_0, B09.

This is not specific to my functions. Same is true for internal (non-published) RTL functions.

This is not mangling. Mangling is a way to decorate name with type information. For example: @Winapi@Commctrl@initialization$qqrv. This is a completely different thing. Additionally, "Map with mangled names" option is set to False. If I set it to True - mangled version for _16386 will become something like @Winapi@Commctrl@_16386.

It is certainly not a problem for typical application runs, because there are no references to that function via its name. However, if I am going to use something like exception tracer tool (or even MS Process Explorer - assuming that I will convert C++ Builder symbols into MS DBG format) - this tool will use produced symbols/debug info and will show me the _16386 name. And I have no idea what code this name refers to!

Why does compiler/linker do that? Is there any way to stop it doing so?

P.S. All tests run with the default Debug profile, which means "Disable all optimizations" and "Full debug info" options are enabled.

  • Is this true also if you compile without optimizations? – dfrib Aug 28 '20 at 10:23
  • 1
    @dfri Yes, this is a default Debug profile, which means "Disable all optimizations" and "Full debug info". – Александр Кулагин Aug 28 '20 at 10:39
  • Every C++ compiler performs some form of name mangling and how those mangled names are supposed to look like is not defined by the standard. Unless the compiler has some flag to control this feature the only way to stop it would be by marking your functions as `extern "C"`(with all the other consequences of that) – UnholySheep Aug 28 '20 at 11:10
  • 1
    @UnholySheep No! It is not mangling. Mangling is a way to decorate name with type information. For example: "@Winapi@Commctrl@initialization$qqrv". This is a completely different thing. Anyway, "Map with mangled names" option is set to False. If I set it to True - mangled version for _16386 will be something like "@Winapi@Commctrl@_16386". – Александр Кулагин Aug 28 '20 at 12:10

0 Answers0