Rephrase readme
Add readme, license and gitignore
makefile improvements
A small tool to generate compatible Hare types and function declarations from a C header file.
Requires Bison, Flex and a C compiler to build.
# builds c2ha
$ make
This tool doesn't check that the C header is correct, you should confirm this using a real compiler first. First, preprocess the header file with the following command.
$ gcc -E -P MyHeader.h > preprocessed.h
Next, pass the preprocessed header file top c2ha
.
$ ./c2ha < preprocessed.h > output.ha
Note that c2ha
doesn't handle many part of valid C at this time so you may need to remove code from the preprocessed header file before converting it.
See input.h
for an example header file that c2ha
can parse.
Note that #define FOO 1
is understood by c2ha
but will be removed during preprocessing.
To generate hare code for simple macros, you can create a separate header for macros.
Only trivial decimal integer macros are supported right now.
# this is definitely not perfect but it should catch the most macros that c2ha understands.
$ grep -E '^#define[[:space:]]+\w+[[:space:]]+[[:digit:]]+[^\\]$' MyHeader.h > defines.h
$ ./c2ha < defines.h > defines.ha