Like Tree1Likes
  • 1 Post By Elkvis

GCC: error check only

This is a discussion on GCC: error check only within the C++ Programming forums, part of the General Programming Boards category; Is there a way to "compile" code with GCC while only actually emitting errors, i.e. get the errors/warnings from compiling ...

  1. #1
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    995

    GCC: error check only

    Is there a way to "compile" code with GCC while only actually emitting errors, i.e. get the errors/warnings from compiling but not actually compile and creating a file? I ask because I want to check a very large codebase for errors without having to actually compile. It will easily compile without problems, but my bottleneck in the compiling time is the hard drive. I don't actually need the compiled object files, just the errors.

    If nothing else, I suspect that you could direct the output to /dev/null so that writing the output file never takes place. Thoughts?

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    995
    Thanks, I saw that when looking earlier, but syntax seems vague, thought for sure it literally only checked language syntax, not errors/warnings.

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,272
    Many warnings are only reported when compiling with optimization, as data-flow tracking is necessary to find for instance uninitialized variables etc. A syntax-only check will reliably detect syntax errors but won't report every error/warning that could occur.

    If you use the "-pipe" option to gcc, and output the resulting .o to /dev/null, you should avoid any disk accesses.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    What about using -S to avoid running the assembler at all? You'd still want to direct the resulting .s files to /dev/null.

    Actually, how would you direct output (.s or .o) to /dev/null ?
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,272
    Quote Originally Posted by oogabooga View Post
    Actually, how would you direct output (.s or .o) to /dev/null ?
    I think "-o /dev/null" would probably work.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    2,588
    it looks to me like option -fsyntax-only is what you're looking for.
    stahta01 likes this.
    Code:
    namespace life
    {
        const bool change = true;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple error check
    By kiwi101 in forum C Programming
    Replies: 25
    Last Post: 11-01-2012, 11:45 AM
  2. Error Check
    By strokebow in forum C++ Programming
    Replies: 5
    Last Post: 02-19-2009, 12:04 PM
  3. How to check error
    By saswatdash83 in forum C Programming
    Replies: 2
    Last Post: 07-16-2008, 05:49 AM
  4. How to error check that input is int or something else
    By sameintheend01 in forum C++ Programming
    Replies: 1
    Last Post: 01-17-2003, 03:04 AM
  5. Check for error in scanf()
    By Dangerous Dave in forum C Programming
    Replies: 5
    Last Post: 12-08-2001, 06:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21