[cfe-commits] r107264 - in /cfe/trunk: lib/CodeGen/MicrosoftCXXABI.cpp test/CodeGenCXX/mangle-ms.cpp
Charles Davis
cdavis at mymail.mines.edu
Wed Jun 30 20:39:46 PDT 2010
On Jun 30, 2010, at 9:27 PM, Sean Hunt wrote:
> On 06/30/2010 07:20 PM, Charles Davis wrote:
>> On 6/30/10 6:04 PM, Sean Hunt wrote:
>>> How does MSVC mangle void foo(int*)? Is it actually different from void
>>> foo(int * const)?
>> The first one is mangled '?foo@@YAXPAH at Z', the second '?foo@@YAXQAH at Z'.
>> So yeah, they're different. Microsoft designed the mangling scheme so
>> that it is possible to recover the entire C++ declaration (with MS
>> extensions, of course) from the mangled name. (IIUC, they did this to
>> enforce the ODR.)
>>
>> Chip
>
> Does the following conforming program fail to link, then?:
>
> // File 1
>
> void foo (int*);
>
> int main() { foo(0); }
>
> // File 2
>
> void foo (int * const) {}
>
> // End of files
Unfortunately yes:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
file1.cpp
file2.cpp
Generating Code...
Microsoft (R) Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.
/out:file1.exe
file1.obj
file2.obj
file1.obj : error LNK2019: unresolved external symbol "void __cdecl foo(int *)" (?foo@@YAXPAH at Z) referenced in function _main
file1.exe : fatal error LNK1120: 1 unresolved externals
And the worst part is that we have to emulate this just for the sake of compatibility.
Chip
More information about the cfe-commits
mailing list