3 ms·
Name mangling is an implementation detail to fit into UNIX linker design space, not the same approach as other compiled languages with modules, with their own l
by pjmlp 3y ago
Name mangling is an implementation detail to fit into UNIX linker design space, not the same approach as other compiled languages with modules, with their own linker.
- gpderetta 3y agoAlso name mangling (which in this case would simply be appending the namespace name to the identifier) would be trivially implementable in C. In fact on some targets the assembler name of identifiers doesn't always match the C name already. Although as someone almost always explicitly qualifies names, typing foo_bar is not very different from foo::bar; the only minor advantages are that you do not have to use foo:: inside the implementation of foo itself and the ability to use aliases.
- planede 3y ago> which in this case would simply be appending the namespace name to the identifier surely not. How do you differentiate these two functions? void fooN(void); namespace N { void foo(void); }
- gpderetta 3y ago[I meant to write prepend, but that doesn't change the argument] You would mangle it as something like foo$N depending on the platform.