, .
1) MinGW (32-bit) + gcc 3.4.4:
---- snip ----
#include<stdio.h>
#include<wchar.h>
const wchar_t BOM = 0xFEFF;
int main(void)
{
int c = BOM;
printf("0x%08X\n", c+0x1000);
return 0;
}
---- snip ----
0x00010EFF. wchar_t . movzwl _BOM, %eax. movSwl, movZwl.
2) FreeBSD 11.2 (64-bit) + clang 6.0.0:
---- snip ----
#include<stdio.h>
#include<wchar.h>
const wchar_t INVERTED_BOM = 0xFFFE0000;
int main(void)
{
long long c = INVERTED_BOM;
printf("0x%016llX\n", c+0x10000000LL);
return 0;
}
---- snip ----
0x000000000EFF0000. wchar_t . , movq $-131072, -16(%rbp). 32- 0xFFFE0000 64- -131072.
3) , 2), RedHat ( ) + gcc 4.4.7: 0x000000000EFF0000. wchar_t .
printf WinAPI WCHAR, wchar_t ( ) C-to-ASM.
Note that the compilers in 1) and 3) are provided by the same provider, namely the GNU project. The answer is definitely platform dependent. (Will anyone test Visual C ++?)
source
share