$ gcc --version
gcc (GCC) 4.6.0
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat redefinesTest.c
/* 12.Jul.2012 kei */
#include <stdio.h>
#include <stdlib.h>
#include <redefines.h>
int main() {
printf("sizeof byte: %d \n", sizeof(byte));
printf("sizeof char: %d \n", sizeof(char));
byte b = 0x2222;
char c = 0x3034;
printf("b: %x \n", b);
printf("c: %x \n", c);
return EXIT_SUCCESS;
}
$ cc -o redefinesTest -I. redefinesTest.c
redefinesTest.c: In function ‘main’:
redefinesTest.c:13:2: warning: overflow in implicit constant conversion [-Woverflow]
$ ./redefinesTest
sizeof byte: 1
sizeof char: 2
b: 22
c: 3034
$
よしよし、ちゃんと警告も出ている。でも include順をまちがうと、大変なことになりそうだな。
多くの文字が 3バイトである UTF-8だと、 c = 'あ'; のようなリテラルの使用はうまくいかない。
愛の照明は?
0 件のコメント:
コメントを投稿