Hacker News new | ask | show | jobs
by milgra 1218 days ago
Very nice collection. My favorite C feature is actually a gcc/clang feature : the __INCLUDE_LEVEL__ predefined macro. It made me code&maintain my C projects exactly twice as fast as before because file count dropped to half : https://github.com/milgra/headerlessc .
5 comments

How does this help? It just moves the content of the .h file to the .c file, but you still need to Write Everything Twice.
It reduces file count in the project browser, renaming/refactoring is much simpler in one file, it just feels like working with a newer language.
Is having two files really that much of a bother? I have my editor set switch between the .c(pp) and the .h with a keyboard shortcut and that seems easier than scrolling between declaration and definition when you want to change something.
I love this. Somehow it feels more elegant than "header-only" libraries.
How do you handle third party headers?
I just include them, everything works as before. If I have to create a library then I create a separate header file for the api functions and only the internals are headerless.
This is great!