I would like to use a similar setup, providing a default config header file in a module but allow the user to add a modified header file to a project. If the modified file exists, it should be included before the fallback/default.
custom/user header example (shortened):
Code: Select all
#ifndef __has_error_conf_h__
#define __has_error_conf_h__
#endif
#ifndef ERROR_CONF_H_
#define ERROR_CONF_H_
// List of task ids
enum {
TASK_1,
TASK_2,
ERR_NUM_TASK_ID /* keep this as the last element! */
};
// task names
static char *taskNames[] = {
"task 1",
"task 2",
"unknown task"
};
/* more definitions */
#endif /* ERROR_CONF_H_ */
Code: Select all
#ifndef ERROR_CONF_EXAMPLE_H_
#define ERROR_CONF_EXAMPLE_H_
#ifdef __has_error_conf_h__
#include "error_conf.h"
#else
enum {
TASK_ID0,
ERR_NUM_TASK_ID /* keep this as the last element! */
};
static char *taskNames[] = {
"Vogon Constructor",
"unknown task ID"
};
#endif
/* default definitions here, #ifndef guarded */
#endif /* ERROR_CONF_EXAMPLE_H_ */