I want to use the htonl function in my ruby c extension, but don’t want to use any of the other internet stuff that comes with it. What would be the most minimalistic file to #include that is still portable? Looking through the header files on my computer, I can see that either machine/endian.h or sys/_endian.h would let me use them, although I am not sure if that is a good idea.
I want to use the htonl function in my ruby c extension, but don’t
Share
The standard header is:
You don’t have to worry about the other stuff defined in that header. It won’t affect your compiled code, and should have only a minor effect on compilation time.
EDIT: You can test this. Create two files, htonl_manual.c
and htonl_include.c:
Assemble them at -O1, then take the difference:
For me, the only difference is the filename.