Binary constants supported by the PGI compiler

Hi,

we have a huge code and we want to compile it with the PGI compiler, we are facing some problems with binary constants:

  
  n = (n ^ (n << 8)) & 0b00000000111111110000000011111111; // (1)
  n = (n ^ (n << 4)) & 0b00001111000011110000111100001111; // (2)
  n = (n ^ (n << 2)) & 0b00110011001100110011001100110011; // (3)
  n = (n ^ (n << 1)) & 0b01010101010101010101010101010101; // (4)

When we compile the code we get a lot of errors of the form:
PGC-S-0039-Use of undeclared variable b00000000111111110000000011111111

Is there a PGI compiler flag to support binary constants?

Thank you for your help

Hi Peter85,

Sorry, but the GNU extension for binary constants is not supported in our older C compiler, but is in our new C compiler (pgcc18). Assuming you’re using PGI 19.10, can you try using “pgcc18” instead?

“pgcc18” is currently in Beta but we’re expecting to make it the default early next year where it will be renamed to “pgcc” and the legacy “pgcc” renamed to “pgcc11”.

% cat bin.c
#include <stdio.h>
#include <stdlib.h>

int main() {

  unsigned long n;
  n = 12345678;
  n = (n ^ (n << 8)) & 0b00000000111111110000000011111111; // (1)
  n = (n ^ (n << 4)) & 0b00001111000011110000111100001111; // (2)
  n = (n ^ (n << 2)) & 0b00110011001100110011001100110011; // (3)
  n = (n ^ (n << 1)) & 0b01010101010101010101010101010101; // (4)

  printf("%lu\n",n);

   exit(0);
}
% pgcc bin.c
PGC-S-0037-Syntax error: Recovery attempted by deleting integer 0 (bin.c: 10)
PGC-S-0039-Use of undeclared variable b00000000111111110000000011111111 (bin.c: 10)
PGC-S-0037-Syntax error: Recovery attempted by deleting integer 0 (bin.c: 11)
PGC-S-0039-Use of undeclared variable b00001111000011110000111100001111 (bin.c: 11)
PGC-S-0037-Syntax error: Recovery attempted by deleting integer 0 (bin.c: 12)
PGC-S-0039-Use of undeclared variable b00110011001100110011001100110011 (bin.c: 12)
PGC-S-0037-Syntax error: Recovery attempted by deleting integer 0 (bin.c: 13)
PGC-S-0039-Use of undeclared variable b01010101010101010101010101010101 (bin.c: 13)
PGC/x86-64 Linux 19.10-0: compilation completed with severe errors
% pgcc18 bin.c
% a.out
1364267092

-Mat

Thank you for the info! We are still using 19.3 ~ 19.9 but I will request an update to 19.10.

FYI, pgcc18 is included with all 2019 compilers so you should have it available.

Thank you for the information! It worked!