r-lib / cpp11

cpp11 helps you to interact with R objects using C++ code.
https://cpp11.r-lib.org/
Other
193 stars 46 forks source link

Use Intel specific pragma to disable unknown attribute warning #278

Closed DavisVaughan closed 1 year ago

DavisVaughan commented 1 year ago

See https://github.com/r-lib/systemfonts/issues/98 for the original issue. That issue turned out to be a different error, but this PR still silences the warning that appeared there. The original issue poster confirmed that this PR fixed the warning.


On the Intel compiler (icpc), it looks like our pragmas to disable unknown attribute warnings are not working, i.e. in the original issue the user saw:

In file included from caches.cpp(1):
caches.h(22): warning #3924: attribute namespace "cpp11" is unrecognized
  [[cpp11::init]]

On the Intel compiler, it looks like you disable warnings using the diagnostic number instead, in this case that is the #3924 you see in the warning output above. The following two resources support this. In particular, the second resource disables the exact warning that we are also trying to disable, so it serves as a good reference:

To detect the Intel compiler, we need to look for __INTEL_COMPILER. But it seems like the Intel compiler also defines __GNUC__, so I've tweaked the defines a little to reflect that. See the GCC C/C++ and Intel C/C++ sections of the following resource: