nvcc error printout format ever so slightly different from gcc

Has anyone noticed that nvcc’s error print format is just slightly different from gcc’s?

$ gcc -o test test.c

test.c: In function ‘main’:

test.c:3: error: ‘a’ undeclared (first use in this function)

test.c:3: error: (Each undeclared identifier is reported only once

test.c:3: error: for each function it appears in.)
medwick:test joaander$ mv test.c test.cu

medwick:test joaander$ nvcc -o test test.cu

test.cu(3): error: identifier "a" is undefined

Note that there are parentheses around the line number in nvcc’s output. This annoyingly makes IDEs (like XCode) interpret that line as random stdout junk and not an file:line error indicator, and thus the cool GUI features for going to errors are not enabled.

Does anyone know if there is a hidden command line option for a gcc-compatible error format? Or is the only option a hackish perl nvcc replacement that translates the error formats?

Pisses me off too. I don’t believe there is a command line option but here’s my hacky solution: Append the following to your nvcc command:

2>&1 | sed -r "s/\(([0-9]+)\)/:/g" 1>&2

E.g. my qmake project file now has this line:

cuda.commands = $$CUDA_DIR/bin/nvcc $$NVCCFLAGS $$CUDA_INC $$LIBS -c ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} \

                2>&1 | sed -r \"s/\(([0-9]+)\)/:\1/g\" 1>&2

Now works ok with QtCreator as far as I can tell. It is just a hack so it will break for weirdly named files and so on (but then the whole console-based compiler-IDE interface is an ugly hack anyway… bring on clang!)

For usability issues such as this, please feel free to file a request for enhancement (RFE) against the compiler through the bug reporting mechanism which is linked from the registered developer website.

As an old-school makefile user I have no knowledge of IDE-to-commandline interfaces but could imagine that different IDEs have different requirements for error message formats, in which case one format may not satisfy all commonly used IDEs.

Ok I submitted it. I suspect that ()'s may be used to work with VC++, but in that case a command line option, and/or platform detection should be used.

Also, communicating through stderr is such an idiotic way to integrate programs. I’m so glad clang is finally fixing this with a proper library interface.