I'm collaborating on an opensource project where the global compiler settings include -Werror
and -pedantic
, so in order to have my contributions accepted, I'll have to comply with those.
Second, I'm a Windows person, so I have happily built a new component of this project, only to realize now that it doesn't compile on Linux, throwing the following warning:
style of line directive is a GCC extension
on every single line (on every 3rd char to be specific) of a CUDA (.cu) source file that is part of my component.
I'm using cmake with the FindCUDA.cmake
scripts to compile CUDA. The source file doesn't contain any #line
directive so I'm completely clueless as to what GCC is complaining about.
First I thought it was line-endings, but the Linux "file" command reports the .cu
file as "C source, ASCII text", no "with CRLF line terminators".
The rest of the opensource project doesn't contain any CUDA, so I have nothing to compare with.
What does this warning mean exactly, and how do I get rid of it?
I think what is happening is that nvcc is generating C source from your .cu
source files for gcc to consume, and in so doing it is including gcc-style line directives of the form #1234
. By compiling this intermediate C code with gcc -pedantic
you then get a problem because these are gcc-style line directives and are non-standard. The solution is to not use -pedantic
, at least for the CUDA part of the project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With