HOW TO: Jump to GNU GCC generated warnings and errors using 'F4'?

Hi,

I'm using visual studio 2005 express, just as an IDE for the development of Gameboy Advance game projects.

I'm compiling c code, using the GNU toolchain and getting output such as:

source/map.c:50: error: conflicting types for 'MAP_put_tile'

source/map.c:35: error: previous implicit declaration of 'MAP_put_tile' was here

source/map.c: In function `MAP_ingame_scroll':

source/map.c:87: warning: assignment makes pointer from integer without a cast

source/map.c:88: warning: assignment makes pointer from integer without a cast

Now I know when visual studio compiles code it reports warnings and errors in the output window something like:

folder/file.c[37]: some error etc etc.

I can just press F4 and jump direct to the error.

My question is, is there any way I can do this for warnings and errors generated by the GNU toolchain (i.e. in the folder/file.c:37: format)



Answer this question

HOW TO: Jump to GNU GCC generated warnings and errors using 'F4'?

  • Asha

    type "make -r 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/'" as your make command (or "Build command line") when you create a new project.

    To change an existing one (in 2005 I cant remember express off the top of my head)

    Go to: Project ->Properties->Configuration Properties-> NMake -> Build Command Line and change it to the above...this will replace gcc line numbers with VS compatible error messages.

    I am looking into making a proper template (that hopefully does not rely on a generic gnu make file behind the scenes) but am having trouble finding info that would enable me to intercept calls to the compiler and linker while maintaining dependency support.


  • shelter

    there isn't any way to specify the format of warnings/errors to Visual Studio; the format must match the format of the Microsoft tools in order for VS to understand it and enable the "goto next error" functionality.

    you could, I suppose, write a perl script or the like to filter the results from gcc into a format that we understand.

    josh

    VC++ project system developer



  • fred1

    make sure your sed filter outputputs the exact path to the source file, otherwise the jump won't work.

    The sed included with SFU does not seem to support the \+ operator, so I used \{1,4\} etc.

    make | sed -e "s/^\(.*\)\([a-zA-Z]\{1,3\}\):\([0-9]\{1,4\}\):/..\/..\/\1\2(\3) :/"

    ~S


  • mrplatypus

    Actually one approach thats not widely used is the try/catch methods in the C++ langage. eg.

    try f=open("object.dat);

    ......

    catch cerr << " open failed"; exit(1);

    .....



  • HOW TO: Jump to GNU GCC generated warnings and errors using 'F4'?