0

i would like to understand the @@YAHXZ part of such an error:

Error LNK2019 unresolved external symbol "int __cdecl func2(void)" (?func2@@YAHXZ) referenced in function _main .

this is just one example but i've seen other types of strange letters i just dont remember them right now. where can i find an explanation on each of them?

valiano
  • 16,433
  • 7
  • 64
  • 79
shl mig
  • 19
  • 1
  • Here is the key: https://learn.microsoft.com/en-us/cpp/build/reference/decorated-names – Edgar Rokjān Dec 04 '17 at 19:57
  • Read about name mangling [here](https://stackoverflow.com/questions/1314743/what-is-name-mangling-and-how-does-it-work) and [here](https://en.wikipedia.org/wiki/Name_mangling). Keep in mind every implementation has it's own name decorating scheme, which can change due to compiler flags and with every compiler version. – François Andrieux Dec 04 '17 at 19:57

1 Answers1

4

This is called «name mangling», or «name decoration».

As C++ supports function overloading, the name of the symbols are generated in a specific way, usually based on the argument's types.

Here's the official documentation on Microsoft website:
https://msdn.microsoft.com/en-us/library/56h2zst2.aspx

EDIT

Microsoft doesn't provide a complete documentation about name decoration.
If you're interested in knowing exactly what the symbols mean, I recommend reading Agner Fog's documentation on calling conventions:
http://www.agner.org/optimize/calling_conventions.pdf

Macmade
  • 52,708
  • 13
  • 106
  • 123
  • 1
    Unfortunately, the official documentation does not document the actual scheme used. It only explains in general terms what a decorated name is. [This source](https://en.wikiversity.org/wiki/Visual_C%2B%2B_name_mangling) seems to explain in more detail though it's a wiki and doesn't specify for which versions it's accurate. – François Andrieux Dec 04 '17 at 20:02
  • @FrançoisAndrieux That's right, unfortunately. Added a link to provide more infos on this. – Macmade Dec 04 '17 at 20:10