When you write a C port you may experience some problems with unpacking erlang records, that were sent to port with term_to_binary/1<br><br>I thought that it would be very nice to write:<br><br>port_command(Port, term_to_binary(#trade_event{price = Price, volume = V}))<br>
<br>and then write in C:<br><br>struct trade_event *evt = read_trade_event(buf, &idx);<br>handle(evt->price, evt->volume);<br><br>So I've written <a href="https://github.com/maxlapshin/record2ei">https://github.com/maxlapshin/record2ei</a><br>
<br>This is a small and very dumb generator of C header and C source that generates C structures and their encoding/decoding functions that calls boilerplate code likeĀ  ei_decode_long or ei_encode_binary.<br><br>It is very limited, yet it helped to me.<br>
<br>