■long 32bit=4byteではなくなったがintは32bitのまま gcc LP64モードで long は64bit=8byteです。U4の様な型定義はサイズが変わってしまいます。よく間違えますがLP64モードで… 続きを読む 【C言語】64bitへ移行(gcc版)
タグ: 型変換
【C言語】
size_t型のprintf書式は %zu,%zx
warning: format specifies type ‘int’ but the argument has type ‘unsigned long’ 警告: %dは… 続きを読む 【C言語】
size_t型のprintf書式は %zu,%zx
【C言語】
0xFFFFffffが-1になり -1が255になる 暗黙の型変換とは?
warning: comparison of integer expressions of different signedness: ‘signed char’ and ‘unsigned int’ 警告:符号の異なる… 続きを読む 【C言語】
0xFFFFffffが-1になり -1が255になる 暗黙の型変換とは?
【C言語】
64bit gccのintのサイズは
64bit(8byte)じゃない
(style): int result is returned as long value. If the return value is long to avoid loss of information, then … 続きを読む 【C言語】
64bit gccのintのサイズは
64bit(8byte)じゃない
【C言語】
ポインタは負になるか?
(void *)-1の使い方
warning: ordered comparison of pointer with integer zero 警告:整数の0とのポインタの比較[-Wextra] ■1.ポインタは負値にならない 成功時ポインタを返し失… 続きを読む 【C言語】
ポインタは負になるか?
(void *)-1の使い方
【C言語】
整数を扱うならばint型を使おう
除夜の鐘を数える変数の型は?
warning: cast from ‘char *’ to ‘int *’ increases required alignment from 1 to 4 警告:整数を… 続きを読む 【C言語】
整数を扱うならばint型を使おう
除夜の鐘を数える変数の型は?
【C言語】
整数表現で int より狭いchar/short型を多用すると
符号拡張の事故にあう
warning: conversion to ‘size_t’ from ‘short’ may change the sign of the result 警告:shor… 続きを読む 【C言語】
整数表現で int より狭いchar/short型を多用すると
符号拡張の事故にあう
【C言語】
引き算の結果をゼロと比較するのは避けよう
warning: comparison of unsigned expression in ‘< 0’ is always false 警告:符号無しは負値にならない [-Wtype-limits] ■uint8_… 続きを読む 【C言語】
引き算の結果をゼロと比較するのは避けよう
【C言語】
enumは
符号付き(signed)か?
符号無し(unsigned)か?
warning: result of comparison of unsigned enum expression < 0 is always false 警告:unsigned enum 式 < 0 の比較… 続きを読む 【C言語】
enumは
符号付き(signed)か?
符号無し(unsigned)か?
【C言語】
switch(狭い型)
case 大き過ぎ
warning: case label value exceeds maximum value for type 警告:caseの値が型の最大値を超えています[-Wswitch-outside-range] ■1.swi… 続きを読む 【C言語】
switch(狭い型)
case 大き過ぎ
【C言語】
コンパイラによっては
int型の 1ビットフィールドは
【0/-1】しか取れない
warning: comparison is always false due to limited range of data type 警告:データ型の範囲制限ため比較は常に偽になります。[-Wtype-limits… 続きを読む 【C言語】
コンパイラによっては
int型の 1ビットフィールドは
【0/-1】しか取れない
【C言語】
配列の添字の型は何が良い?
warning: the frame size of 40 bytes is larger than 0 bytes 警告:スタックフレームサイズは0byte以上の40byte[-Wframe-larger-than=0… 続きを読む 【C言語】
配列の添字の型は何が良い?
【C言語】
無限ループが発生する
for文のバグ
(infinite loop)
warning: comparison is always true due to limited range of data type 警告:データ型の幅が限られているため、比較は常に真である。[-Wtype-limi… 続きを読む 【C言語】
無限ループが発生する
for文のバグ
(infinite loop)