Installing Bit::Vector on Debian 13 (Trixie)
Whilst Bit::Vector is available as a Debian package in libbit-vector-perl, when installing it using cpanm the compile failed for me.
The installation crashed during the make stage, throwing a specific compiler error regarding false and true tokens:
Building Bit-Vector-7.4
...
cc -c -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -DVERSION=\"7.4\" -DXS_VERSION=\"7.4\" -fPIC "-I/home/dean/perl5/perlbrew/perls/perl-5.40.3/lib/5.40.3/x86_64-linux-thread-multi/CORE" BitVector.c
In file included from BitVector.c:12:
ToolBox.h:98:20: error: cannot use keyword 'false' as enumeration constant
98 | enum { false, true };
| ^~~~~
ToolBox.h:98:20: note: 'false' is a keyword with '-std=c23' onwards
make: *** [Makefile:343: BitVector.o] Error 1
-> FAIL Installing Bit::Vector failed.
Why this happens:
The issue stems from modern Linux distributions upgrading their default compiler (like GCC 15+) to use the C23 (ISO C 2023) standard. In C23, false and true became official, reserved language keywords[cite: 2]. Because Bit::Vector is an older module, its internal ToolBox.h file explicitly tries to define them inside an enum block for legacy compatibility, which modern C23 compliance strictly forbids[cite: 2].
A solution that worked was:
cpanm --configure-args="OPTIMIZE='-O2 -std=gnu17'" Bit::Vector
What this does:
-
--configure-args
Passes arguments directly to the underlyingMakefile.PLbuild script[cite: 2]. -
OPTIMIZE='-O2 -std=gnu17'
Overrides the default compiler optimization settings[cite: 2]. It keeps standard-O2optimization performance but strictly forces the compiler to treat the codebase as GNU C17 instead of C23[cite: 2]. This bypasses the keyword restrictions and allows the legacyenumdeclaration to succeed flawlessly[cite: 2].
Hopefully this will help someone else running into the same roadblock!
I blog about Perl. I am back in Sydney
Leave a comment