HackRVA / Badge2017-docs

0 stars 3 forks source link

Added section on header files #15

Closed alflanagan closed 7 years ago

alflanagan commented 7 years ago

I've added a recommendation that all functions should have prototypes in header files. This is very useful for catching bugs that can be really hard to track down otherwise.

Also of note: we have -w passed as an option to turn off all warnings from the compiler. I realize the warnings can be annoying, but it's good practice to turn them on and correct each one. Again, the aim is to prevent difficult bugs.

dotblank commented 7 years ago

While I do think it is a good idea to make code easier to debug, I am concerned with scope.

I'd rather not have: somefile.c somefile.h and somefile-private.h

But if debugging outweighs the need to encapsulate than count me in

alflanagan commented 7 years ago

All right, dammit, I merged my own pull request through user error. Please review and I'll reverse/revise as necessary.

Matt5sean3 commented 7 years ago

The only thing I have to say is that mention could be made of static functions and that they should not be added in the header for obvious reasons (by definition they can't be called from a different file). I suspect this may be what you're talking about with private functions and the people who know what static functions are and why to use them will probably understand this without it needing to be said explicitly so maybe that's unnecessary. I can't really find anything I object to so personally, I see no need to revert or revise.

alflanagan commented 7 years ago

Thanks @Matt5sean3. Actually, that's a good point about static functions: we should probably add a recommendation that all functions not meant to be called by others should be static.