1

C++ compilers mangle names (or signatures rather) because in C++, the same name of a function or variable can be overloaded (e.g. different parameters, different namespace, different template parameters).

Now, we all know and love the c++filt utility which demangles names (e.g. from standard input) - without using a compiler infrastructure. But can I do the opposite, i.e. mangle the names, without compiling any code?

Assume that I just have the signatures coming in on standard input, one line at a time or whatever is convenient. The input does not contain any macros, or expressions, or any such thing. Unlike in this question, I would like answers that do not involve compiling code, nor using the infrastructure of a compiler to sort-of-compile it.

Community
  • 1
  • 1
einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    Related: [What is Linux utility to mangle a C++ symbol name?](http://stackoverflow.com/q/11335624) – Basilevs Jan 21 '16 at 03:27
  • 2
    Possible duplicate of [C++ name mangling by hand](http://stackoverflow.com/questions/4667266/c-name-mangling-by-hand) – Basilevs Jan 21 '16 at 03:28
  • A fully functional mangler would need a substantial subset of a C++ compiler functionality – n. m. could be an AI Jan 21 '16 at 04:09
  • Why would you require not to compile some code? You should be able to write a simple script that constructs a snippet to compile and then pass it to the compiler and finally extract the mangled name. – skyking Jan 21 '16 at 06:37
  • @skyking: Because I might want to do the mangling at runtime, and I would rather not invoke a C++ compiler, I feel it's overkill. – einpoklum Jan 21 '16 at 09:23
  • @Basilevs: Well, most of the answers there tell you to compile code in order to achieve mangling. But you be the judge about duplicateness. – einpoklum Jan 21 '16 at 09:25
  • Question is a duplicate, not answers. – Basilevs Jan 21 '16 at 13:23
  • @Basilevs: So, no. This question is about mangling without compiling, that one is about just mangling. LIke a question on sorting an array, and a question on sorting it without the standard library's sort. – einpoklum Jan 21 '16 at 14:25
  • Related: [Getting mangled name from demangled name](http://stackoverflow.com/q/12400105) – Basilevs Jan 21 '16 at 14:36

0 Answers0