ファイルのコンパイルでエラーが出ます。実行結果のようになります。
エラーの箇所に間違いがないか見たのですが、間違いはないように見えます。
よろしくお願いいたします。
ファイル名 random.c #include "random.h" static unsigned long int random_value=1; //乱数系列の初期化 void random_init(unsigned long int seed) { random_value = seed; get_random_value(); return; } #define MASK (1 << 6 ) | (1 << 4) | (1 << 2) | (1 << 1) |(1 << 0)) static void random_rotate() { if(random_value & (1 << 31)){ random_value = ((random_value ^MASK) << 1) | 1; }else{ random_value <<= 1; } return; } //乱数を返す unsigned long int get_random_value() { int i; for(i=0; i<32 ; i++) random_rotate(); return (random_value); } 実行結果 naka@naka ~/sample/lib_list $ gcc -c random.c -Wall random.c: In function 'random_rotate': random.c:28:33: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses] random_value = ((random_value ^MASK) << 1) | 1; ^ random.c:28:44: error: expected ';' before ')' token random_value = ((random_value ^MASK) << 1) | 1; ^ random.c:28:44: error: expected statement before ')' token random.c:28:46: error: expected expression before '|' token random_value = ((random_value ^MASK) << 1) | 1;
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/03/25 06:15