I have a lot of functions to declare in this format:
int foo_100(int, int);
int foo_200(int, int);
int foo_300(int, int);
int foo_400(int, int);
typedef int (*foo)(int, int);
struct foo foo_library[] = {
foo_100,
foo_200,
foo_300,
foo_400
};
Is there a way I can use the C preprocessor to partially automate this task? Ideally, something like this:
foo.txt
100
200
300
400
foo.h
typedef int (*foo)(int, int);
#define DEFINE_FOO(id_) int foo_##id_(int, int);
DEFINE_FOO(#include"foo.txt")
struct foo foo_library[] = {
#include "foo.txt"
};