PLC-lang / rusty

Structured Text Parser and LLVM Frontend
GNU Lesser General Public License v3.0
181 stars 47 forks source link

Support exporting a C header from a PLC Interface #1203

Open ghaith opened 1 month ago

ghaith commented 1 month ago

Is your feature request related to a problem? Please describe. When writing external Libraries in different languages, we have to write the interfaces by hand. It would be good if we could simply generate the given C header file for a given PLC project.

Describe the solution you'd like Using a new command like plc generate ffi -o header.h we could generate headers for the project. The command will generate a C header in header.h. If no output is provided, it will be output on stdout.

The documentation should be updated to reflect how to create external libraries. We should define a C standard for the definition, and use appropriate data types.
I suggest we use the fixed size integer types from C99 defined in stdint.h The double_tand float_ttypes from math.h The char8_t and char16_t from wchar.h (C11) for CHAR and STRING types.

Describe alternatives you've considered Writing headers by hand.