capstone-engine / capstone

Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
http://www.capstone-engine.org
7.61k stars 1.56k forks source link

Replace non-standard 0b(...) literals #2314

Closed thestr4ng3r closed 6 months ago

thestr4ng3r commented 7 months ago

Your checklist for this pull request

Detailed description

Despite being widely implemented and part of C++, the 0b prefix is not part of any C standard and will be rejected by some compilers such as Apple GCC 4.0.1 (5493).

imac:capstone florian$ make
  CC      cs.o
In file included from include/capstone/capstone.h:360,
                 from cs.c:17:
include/capstone/arm.h:128:11: error: invalid suffix "b1000" on integer constant
include/capstone/arm.h:129:12: error: invalid suffix "b0100" on integer constant
include/capstone/arm.h:130:12: error: invalid suffix "b1100" on integer constant
include/capstone/arm.h:131:13: error: invalid suffix "b0010" on integer constant
include/capstone/arm.h:132:13: error: invalid suffix "b0110" on integer constant
include/capstone/arm.h:133:13: error: invalid suffix "b1110" on integer constant
include/capstone/arm.h:134:13: error: invalid suffix "b1010" on integer constant
include/capstone/arm.h:135:14: error: invalid suffix "b0001" on integer constant
include/capstone/arm.h:136:14: error: invalid suffix "b0011" on integer constant
include/capstone/arm.h:137:14: error: invalid suffix "b0111" on integer constant
include/capstone/arm.h:138:14: error: invalid suffix "b0101" on integer constant
include/capstone/arm.h:139:14: error: invalid suffix "b1111" on integer constant
include/capstone/arm.h:140:14: error: invalid suffix "b1101" on integer constant
include/capstone/arm.h:141:14: error: invalid suffix "b1001" on integer constant
include/capstone/arm.h:142:14: error: invalid suffix "b1011" on integer constant
In file included from include/capstone/capstone.h:364,
                 from cs.c:17:
include/capstone/ppc.h:127:19: error: invalid suffix "b10000" on integer constant
include/capstone/ppc.h:128:18: error: invalid suffix "b01000" on integer constant
include/capstone/ppc.h:129:20: error: invalid suffix "b00100" on integer constant
include/capstone/ppc.h:130:19: error: invalid suffix "b00010" on integer constant
include/capstone/ppc.h:131:13: error: invalid suffix "b00001" on integer constant
include/capstone/ppc.h:139:21: error: invalid suffix "b00" on integer constant
include/capstone/ppc.h:140:20: error: invalid suffix "b01" on integer constant
include/capstone/ppc.h:141:21: error: invalid suffix "b10" on integer constant
include/capstone/ppc.h:142:17: error: invalid suffix "b11" on integer constant
include/capstone/ppc.h:143:21: error: invalid suffix "b11" on integer constant
make: *** [cs.o] Error 1
imac:capstone florian$ cc --version
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Test plan

Build with a compiler that does not support 0b.

aquynh commented 6 months ago

merged, thanks!