Is it completely unheard of to have a .c
file dedicated to just data? In my case, I'd be using it for global variables that are shared across two other .c
files. Here's specifically how I'm using it.
// serverth.h
struct serverth_parameters {
struct { // right now, this is the only struct needed
char * root,
* user,
* public,
* site;
} paths;
// I anticipate needing another struct here
};
#ifndef SERVERTH_SOURCE
extern struct serverth_parameters parameters;
#endif
// serverth.c
#define SERVERTH_SOURCE
#include "serverth.h"
struct serverth_parameters parameters = {
.paths = { // macros are actually used here
"/srv",
"/user",
"/public"
"/site"
}
};
parameters
is a struct that's used for a websockets server, in two files:
- One for HTTP (uses
parameters.paths.site
) - Two for proprietary protocols (both use
.paths.user
, one usespaths.public
)
Is this a bad practice? Do people do this? Or, is it more conventional to just keep the data in the source file in which it is most relevant?