Reputation: 715
I'm implementing foreign function interface for my toy language. Instead of writing compatible declarations manually, I want to reuse C header files provided by operating systems.
How can I get binary interface (such as types of function parameters, memory layout of a structures, type alignments, optimization hints) for a specific platform from C header files? Is there any way to use Clang or GCC to do that?
Upvotes: 4
Views: 148
Reputation: 16133
Use -dump
option of the abi-compliance-checker tool. It will create the ABI dump of the input header files. Add -xml
option to produce XML output.
In your case you need the following input XML descriptor (descriptor.xml):
<version>
1.0 /* any version */
</version>
<headers>
/path1/to/headers
/path2/to/headers
...
</headers>
The command to run the tool:
abi-compliance-checker -l ANY_NAME -dump descriptor.xml -headers-only
The additional -headers-only
option in the command is needed if you have not specified any shared libraries in the descriptor (in the <libs>...</libs>
section of the XML descriptor).
Upvotes: 3