x86およびx86_64マシンでint16_t
をコンパイルしているのにint16_t complex
がコンパイルされない理由は、short int
のtypedefですか?以下は、gcc 5.4と4.9とC99とC11の両方の標準でテストされたサンプルコードです。コンパイラは、宣言指定子に2つ以上のデータ型を持つことについて不平を言います。なぜ 'int16_t complex'が機能しないのですか?
コード:
#include <complex.h>
#include <stdint.h>
#include <stdio.h>
int main()
{
float complex x = I + I/3 * I/2;
short int complex y = I + I/3 * I/2;
int16_t complex z = I + I/3 * I/2; /* Why ? */
printf("x=(%+f,%+f)\n", creal(x), cimag(x));
printf("y=(%+f,%+f)\n", creal(y), cimag(y));
printf("z=(%+f,%+f)\n", creal(z), cimag(z)); /* Why ? */
return 0;
}
エラー:
In file included from ./complex.c:1:0:
./complex.c: In function ‘main’:
./complex.c:9:13: error: two or more data types in declaration specifiers
int16_t complex z = I + I/3 * I/2; /* Why ? */
コンパイラのコマンドライン:
gcc-5 --std=c99 ./complex.c -o ./complex
gcc-4.9 --std=c99 ./complex.c -o ./complex
C99モード( '-std = c99')で実行しているときに' short int complex'が受け入れられますか?警告レベルを上げることを検討してください。 – alk
@alkはい。 '--pedantic'と' -Wall -Werror'を使っても –