If you use GCC, you can do this with a function attribute constructor, for example:
#include <stdio.h>
void foo() __attribute__((constructor));
void foo() {
printf("Hello, world!\n");
}
int main() { return 0; }
However, in C there is no portable way to do this.
, . , :
#define CONSTRUCTOR_METHOD(methodname)
CONSTRUCTOR_METHOD(foo)
build script CONSTRUCTOR_METHOD .c. main().