bubu (bubu) rakstīja koderi kopienā, |
C:\test>type a.cpp
#include <string>
// deklaraacijas
extern "C" std::string foo;
extern std::string bar;
// definiiicjas
std::string foo;
std::string bar;
C:\test>cl /c /EHsc a.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
a.cpp
C:\test>objdump --syms a.obj | grep foo
[149](sec 50)(fl 0x00)(ty 20)(scl 3) (nx 0) 0x00000000 ??__Efoo@@YAXXZ
[197](sec 65)(fl 0x00)(ty 20)(scl 3) (nx 0) 0x00000000 ??__Ffoo@@YAXXZ
[207](sec 68)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _foo
[210](sec 69)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 _foo$initializer$
C:\test>objdump --syms a.obj | grep bar
[194](sec 64)(fl 0x00)(ty 20)(scl 3) (nx 0) 0x00000000 ??__Ebar@@YAXXZ
[203](sec 67)(fl 0x00)(ty 20)(scl 3) (nx 0) 0x00000000 ??__Fbar@@YAXXZ
[206](sec 68)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000001c ?bar@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A
[211](sec 69)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000004 _bar$initializer$
C:\test>
bar, kā redzams, nepavisam nav _bar.Nopūsties: