Compilation errors with g++

when compiling with g++, does any one know of any way of making g++ output the line(s) of code the compilation error(s) occurred on?

i can't find anything in the documentation, so i apologise in advance if this is just a case of rtfm...

cheers
I thought g++ already did that.

test.cpp:9:2: error: expected unqualified-id before 'for'

This means the error is on line 9.
I think he means literally outputting the line the problem occurred on. I assume there isn't, but even if there was - what would be the point? Most text editors that don't suck will have an option to show line numbers.
Last edited on
cheers hanst99 yes i did mean that. yes i can get the line number and my text editor will take me there.

but for other reasons i want to be able to output the line the error occurred on. has anyone perhaps seen a switch anywhere that will allow this to happen?
There won't be a switch.

You could print the line. One way is, for filename /tmp/x.cpp and line 24:
cat -n /tmp/x.cpp | grep '^ *24'
I'm sure there are better ways.
sed -n 'p{line_number}' file

does the same thing (I think).
Last edited on
goodo yes i can run with that - cheers!
Topic archived. No new replies allowed.