Home > Software design >  Is it possible to get functions from a filename in C?
Is it possible to get functions from a filename in C?

Time:01-09

I have 3 files 00.c, 01.c, 02.c, each one of these files contains one function, and the 3 functions are accessible by main.c. What I want to do is to run these functions in the right order depending on the file name (call the function inside 00.c, then the one inside 01.c, then 02.c). Is it possible to do that in C (preferably without defining macros)?

CodePudding user response:

Unfortunately not. The functions within a binary are in some undefined order (probably related to the link command line).

This means that functions can not be found in the correct order.

You could use the MACRO FILE to identify the file name of a file, then use a structure with that and the function to call to sort the functions in the required order.

  •  Tags:  
  • Related