#include <stdio.h>
#include <string>
std::string s = "a string";
int main()
{
printf("%s\n", s.c_str());
}
#if 0
实际上由STL定义的数据类型都可以用作全局变量。
#endif
#if 0
/*
* intel
*/
0000000000001229 <main>:
1229: f3 0f 1e fa endbr64
122d: 55 push %rbp
122e: 48 89 e5 mov %rsp,%rbp
1231: 48 8d 3d 08 2e 00 00 lea 0x2e08(%rip),%rdi # 4040 <_Z1sB5cxx11>
1238: e8 83 fe ff ff callq 10c0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv@plt>
123d: 48 89 c7 mov %rax,%rdi
1240: e8 cb fe ff ff callq 1110 <puts@plt>
1245: b8 00 00 00 00 mov $0x0,%eax
124a: 5d pop %rbp
124b: c3 retq
/*
* arm
*/
00000000004009ec <main>:
4009ec: a9bf7bfd stp x29, x30, [sp, #-16]!
4009f0: 910003fd mov x29, sp
4009f4: b0000080 adrp x0, 411000 <__libc_start_main@GLIBC_2.17>
4009f8: 91020000 add x0, x0, #0x80
4009fc: 97ffffa5 bl 400890 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv@plt>
400a00: 97ffffa8 bl 4008a0 <puts@plt>
400a04: 52800000 mov w0, #0x0 // #0
400a08: a8c17bfd ldp x29, x30, [sp], #16
400a0c: d65f03c0 ret
#endif