|
|
|
|
|
by jjgreen
1248 days ago
|
|
One .cc/.h pair, one object Not always the case; I have a project with default.o: default.yaml
$(LD) -r -b binary -o default.o default.yaml
and a default.h containing extern const char _binary_default_yaml_start[];
extern const char _binary_default_yaml_end[];
#define PARAM_YAML _binary_default_yaml_start
#define PARAM_YAML_LEN (_binary_default_yaml_end - _binary_default_yaml_start)
this used in the main code as fwrite(PARAM_YAML, 1, PARAM_YAML_LEN, stdout);
printing the contents of the yaml file to stdout. |
|
Your use case would be served by C23's #embed [1]. The same thing has been proposed for C++ but repeatedly kicked down the road because the standardisation committee wanted to make it more general even though no one had any demand for that so they didn't know what it would look like. (C++ standardisation in a nutshell.)
[1] https://thephd.dev/finally-embed-in-c23