Skip to content

Instantly share code, notes, and snippets.

@toots
Created December 1, 2019 16:40
Show Gist options
  • Save toots/5ace755d660795c39913a2509e870384 to your computer and use it in GitHub Desktop.
Save toots/5ace755d660795c39913a2509e870384 to your computer and use it in GitHub Desktop.
let c_headers = "
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
"
let () =
let fname = Sys.argv.(1) in
let oc = open_out_bin fname in
let format =
Format.formatter_of_out_channel oc
in
Format.fprintf format "%s@\n" c_headers;
Cstubs.Types.write_c format (module Sys_socket_types.Def);
Format.pp_print_flush format ();
close_out oc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment