In said:
But I use static on functions when I write a program
that consists of one translation unit. Is this something
which is frowned upon? Do other people here(comp.lang.c) do
this?
I do that as a rule of thumb. It doesn't hurt.
(kinda pseudo-code)
/* main.c */
/* private functions */
static a()
{
}
static b()
{
}
/* entry point */
int main()
{
a();
b();
}
If the program grows, some of the static could become external functions. In
that case, they will loose the 'static', and some prefix will probably added
to their name. The separated compilation process will be implemented
(separated TU, header etc.)
/* main.c */
#include x.h"
/* private functions */
static a()
{
}
/* entry point */
int main()
{
a();
X_b();
}
/* x.h */
X_b();
/* x.c */
/* private functions */
static a()
{
}
static b()
{
}
/* entry point */
X_b()
{
a();
b();
}
Here are the skeletons I use for code layouts :
Interface (.h)
/* macros ============================================================== */
/* constants =========================================================== */
/* types =============================================================== */
/* structures ========================================================== */
/* internal public functions =========================================== */
/* entry points ======================================================== */
/* public variables ==================================================== */
Implementation (.c)
/* macros ============================================================== */
/* constants =========================================================== */
/* types =============================================================== */
/* structures ========================================================== */
/* private variables =================================================== */
/* private functions =================================================== */
/* internal public functions =========================================== */
/* entry points ======================================================== */
/* public variables ==================================================== */