SKETCH OF HOW RESEARCH MIGHT CONTINUE AND RESULTS BE PRESENTED - PREVIEW ONLY

Name Decoration

C++ provides that even within one source file the same simple identifier may refer to different objects in different circumstances. The intended object is inferred, e.g., from the current scope or from the types of argument passed to an overloaded function. Of course, each object has a fully-qualified name within the C++ source file, but objects with external linkage need to be distinguishable, and even identifiable to some extent, by more or less arbitrary programming tools for more or less arbitrary purposes.

Most notable among such tools is the linker, which ultimately has the job of finding which object defined in which source file is intended by which reference in which (other) source file.

Microsoft is surely sensible—indeed, perfectly so—to warn programmers not to depend on whatever they think they know of any algorithm they suppose Microsoft uses for name decoration. Algorithmic consistency is not required of Microsoft even between different versions of Microsoft’s compiler. What other compilers do for name decoration is not in Microsoft’s hands and is not anything that Microsoft need care to know. That said, Microsoft has itself brought name decoration to greater attention by implementing and documenting the built-in macro __FUNCDNAME__ and providing the UNDNAME.EXE program (which is a front-end for the __unDName and __unDNameEx functions that have long been implemented, but not documented, in the C Run-Time Library).

Syntax

The rules for a symbolic name are ultimately those of the linker, which happen also to be those of Microsoft’s assembler (MASM). The permitted characters are alphanumeric (letters A to Z in upper and lower case, and digits 0 to 9), plus the dollar sign, question mark, @ sign and underscore. The first character, however, cannot be a digit.

The letters, digits and underscore are anyway the characters of C++ identifiers, also with the exception about not starting with a digit. Since the dollar sign, question mark and @ signs are not valid characters in C++ identifiers (discounting for now that $ is allowed in identifiers when the /Ze option is active), they find use in the symbolic name as signifiers and separators.

The general form for a decorated name is to begin with a question mark, name the object and its scope, and continue with whatever attributes, parameters or properties seem helpful.

?name[@][scope@]@parameters

The leading question mark presumably announces that the symbol is for an object with C++ linkage, as opposed to C linkage which has its symbols start with an underscore or @ sign.

The parameters vary, strongly, with the type of object.