I was looking into Raspberry Pi Pico C/C++ SDK code. I found a statement using two inversion (not) operator next to each other.
What is the purpose of double inversion (not operator) in the statement return !!((*(io_ro_32 *)TBMAN_BASE) & TBMAN_PLATFORM_FPGA_BITS);
?
Wouldn't the compiler strip these operation during optimization? What is the purpose of double inversion in a statement next to each other?
Code :
#if !PICO_NO_FPGA_CHECK
// Inline stub provided in header if this code is unused (so folding can be
// done in each TU instead of relying on LTO)
bool running_on_fpga() {
return !!((*(io_ro_32 *)TBMAN_BASE) & TBMAN_PLATFORM_FPGA_BITS);
}
#endif