Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ビット単位の演算子で 2 進数を使用できないのはなぜですか?
//works msgSize = (*(msgbody+1) & 0x80)?*(msgbody+5):*(msgbody+3); //doesn't compile msgSize = (*(msgbody+1) & 0b10000000)?*(msgbody+5):*(msgbody+3);
バイナリ リテラルは C ではサポートされていません。それらが利用可能な場合、それらは拡張機能です。コンパイラがバイナリ リテラルを認識しないため、エラーが発生していることをお勧めします0b10000000。したがって、コンパイラはおそらくこれでもエラーを出力します。
0b10000000
int main(void) { int msgSize = 0b10000000; return 0; }
0x80or1 << 7代わりに使用することをお勧めします。
0x80
1 << 7