Search code examples
cincludeheader-files

Including header files in C


I am working on a project in which If I could include a header file at runtime, it would save some programming effort. I google'd about it, but all in vain. My question is :
Can we include header files in a C program at runtime ?
If yes, how?
If not, why?


Solution

  • Not really, no. Header files are brought in by the compiler to satisfy symbols needed during compilation.

    If you simply want values unrelated to compilation, you can always put them in a configuration file which is read at runtime.

    Other possible solutions are command line arguments or environment variables but, since you're discussing putting them into a file, the first option is probably the best.