Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    -Wall -Werror -Wextra -pedantic
that's all you need


I guess you also need a way to suppress spurious warnings. And C compilers normally don't warn you about follies, like using global mutable state. Or using C where it's inappropriate (or not using C where it's appropriate).

Though I do agree that ridding your code of compiler warnings is a good idea in general. Because when a warning comes up afterwards, it will actually have some signalling value, instead of being ignored in a sea of similar warnings.


> I guess you also need a way to suppress spurious warnings.

    man gcc
    ...
    You can request many specific warnings with options beginning -W, for
    example -Wimplicit to request warnings on implicit declarations.  Each
    of these specific warning options also has a negative form beginning
    -Wno- to turn off warnings; for example, -Wno-implicit.  This manual
    lists only one of the two forms, whichever is not the default.  For
    further, language-specific options also refer to C++ Dialect Options
    and Objective-C and Objective-C++ Dialect Options.
> And C compilers normally don't warn you about follies, like using global mutable state.

I mean no great disrespect, but if you need a machine to remind you not to use global mutable state, get back in the oven, you're still a bit gooey on the inside.


I was just arguing against

  -Wall -Werror -Wextra -pedantic
being __all__ you need. I don't doubt that those options are certainly part of a healthy breakfast.


Thank you. I can't stand it when I build someone's C code and am greeted with page after page of compiler warnings. It gives me a sinking feeling.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: