これがあれば、私は疑問に思っていました:
#define size 8
#if ( 0 < size ) and ( size <= 16 )
static unsigned char value;
#elif ( 8 < size ) and ( size <= 16 )
static unsigned short value;
#elif ( 16 < size ) and ( size <= 32 )
static unsigned value;
#elif ( 32 < size ) and ( size <= 64 )
static unsigned long value;
#else
return 0;
#endif
#undef size
定数で可能ですか?私はもう試した:
const unsigned char size = 8;
if ( ( 0 < size ) && ( size <= 8 ) ) {
static unsigned char value;
} else if ( ( 8 < size ) && ( size <= 16 ) ) {
static unsigned short value;
} else if ( ( 16 < size ) && ( size <= 32 ) ) {
static unsigned value;
} else if ( ( 32 < size ) && ( size <= 64 ) ) {
static unsigned long value;
} else {
return 0;
}
しかし、結果として私は持っています:
致命的なエラー: 宣言されていない識別子 '値' の使用
これは可能ですか?