I need to use 256bit arithmetic in my C++ code on Mac with arm processor.
According to this Stack Overflow answer, C++23 has 256-bit arithmetic via _BitInt(256) and it has been implemented in Clang-16. I just installed it through brew install llvm
and compiling with clang++ outputs
error: unsigned _BitInt of bit sizes greater than 128 not supported.
Am I doing something wrong or is the answer linked above incorrect? I realize that some of the discussion is about C, but claims are made about C++ as well.
The post you linked, Is there a 256-bit integer type in C?, is tagged x86-64 and indeed is applicable only to that architecture. At least up to version 18, clang supports large _Bitint
sizes on x86 and x86-64; but on arm and aarch64, they are currently only supported up to 128 bits. Sorry.
This is not anything specific to the MacOS or homebrew distributions of clang; it also happens for the generic arm/aarch64 compilers used by godbolt.