I have a very special problem, but I hope here is someone who can help me. I am writing a C/C++ program, but I have to deal with legacy libraries written in Structured Text (ST, IEC 61131-3). In ST everything is accessible from nearly everywhere, so nobody did ever care for library dependencies in the past. My IDE automatically generates a C-Header for each legacy ST library. But this results in many hundred C-Header files, with crazy dependencies and a lot of forward declarations. If I try to include any single header from this mess, I end up searching endlessly for the required other headers to include.
Does anybody knows a way to analyze the C-header files to find all necessary files for a given type/file and the correct include order? I already found this tool here: rpvelloso/oneheader But this does not resolve the forward declarations. My compiler (gcc) complains hundred times about incomplete types. I would even accept something monstrous like "LegacyAllInOneHeader.h" which includes all legacy libraries, if I only find a way to use the legacy code.
Additional Info:
- I have no influence on the header file generation
- Header files will have always the same name after each regeneration
- Many headers have circular dependencies
Many thanks in advance for your help.
Example:
ST_Lib1 might result in such a header:
typedef struct type1
{ struct type2 data1[7];
struct type3 data2[7];
} type1;
ST_Lib2 might result in such a header:
typedef struct type2
{ struct int data1[7];
struct type4 data2[7];
} type2;
In my C-Program I need to figure out, which headers are all necessary and the correct order:
//Still need to look up "type3" and "type 4"
#include <ST_Lib2.h>
#include <ST_Lib1.h>
main()
{
//do something
}