无需事先声明就调用C函数

简短版:我想在调用它的同一条语句中声明一个函数。我正在寻找的语法是这种类型的:

// foo is undeclared in this file, and implemented in another file
int main() {
    void* p = (cast_to_function_that_receivs_ints_and_returns_pointer)foo(1,2);
}

长版:

The following code creates an obvious implicit declaration warning and undefined reference error, because of the call to foo:

// a.c
int main() {
    void* p = foo(1,2);
}

I add the following file to the compilation to solve the undefined reference:

// b.c
void* foo(int a, int b) {
    return (void*)0xbadcafe;
}

I would now like to solve the implicit declaration. The usual solution is to modify a.c to either #include a declaration to foo or declare it itself, something like:

// a.c
void* foo(int a, int b);
int main() {
    void* p = foo(1,2);
}

但是,我宁愿不声明foo,而是修改调用foo的行,类似于函数指针语法或我在“简短版本”中发布的示例。可能吗

Assume I am proficient in C and that I have a valid motivation - I would like to "override" the behavior of foo by recompiling with -Dfoo=bar.