There are two tasks I end up doing manually in C a lot and I’d like to not.
Thing one: putting guards around header files.
Any module.h should start with:
#ifndef MODULE_H
#define MODULE_H
and end with:
#endif /* !MODULE_H */
I usually get a few minutes into writing the header file and then remember that I need have an include guard. I’d like to be able to hit a key or select a menu item in order to add it. The name of the guard should be derived from the file name.
Thing two: maintaining function prototypes in header files.
Given a file.c, prototypes for all non-static functions should exist in the counterpart file.h.
So given file.c:
void file_init(int a, int b)
{
/* stuff here */
}
static void helper(void)
{
/* more stuff */
}
void file_scan(int a, int c)
{
/* and again */
}
The corresponding file.h should look contain:
void file_init(int a, int b);
void file_scan(int a, int c);
Again, I’d like to, from a C source file, hit a key or select a menu item to add prototypes in the corresponding C header file. Bonus points if the command creates the header file if it doesn’t exist yet, and adds the appropriate include guard. More bonus points if it can update existing prototypes if I change the return type or parameter list.
Does that all make sense?
I imagine AppleScript would be involved.
Don’t feel like you have to write this for me, but if you already have tools to do this (or part of this) please point me in their direction.
Thanks for any ideas!
-sam
There are two tasks I end up doing manually in C a lot and I’d like to not.
Thing one: putting guards around header files.
[snip]
Thing two: maintaining function prototypes in header files.