saleyn / erlexec

Execute and control OS processes from Erlang/OTP
https://hexdocs.pm/erlexec/readme.html
Other
525 stars 139 forks source link

Replace INT_MAX with std::numeric_limits<int>::max() #161

Closed SteffenDE closed 2 years ago

SteffenDE commented 2 years ago

So my goal is to use erlexec on embedded devices using Elixir's Nerves project for interactive shells (https://github.com/SteffenDE/nerves_ssh_shell) and on musl based systems it complains about limits.h missing:

===> Compiling /Users/steffen/Desktop/MonitorNews/nerves_containers/nerves_ssh_shell/examples/ssh_multi_daemon_example/deps/erlexec/c_src/ei++.cpp
===> In file included from c_src/ei++.hpp:50,
                 from c_src/ei++.cpp:5:
/Users/steffen/.nerves/artifacts/nerves_system_x86_64-portable-1.20.0/staging/usr/include/limits.h:124:26: error: no include path in which to search for limits.h
  124 | # include_next <limits.h>
      |                          ^
In file included from c_src/ei++.cpp:5:
c_src/ei++.hpp:76:28: error: 'INT_MAX' was not declared in this scope
   76 |                 int size = INT_MAX);
      |                            ^~~~~~~
c_src/ei++.hpp:57:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
   56 | #include <sys/time.h>
  +++ |+#include <climits>
   57 | #include <unistd.h>

Including climits does NOT help, but replacing the occurrences of INT_MAX with std::numeric_limits<int>::max() works fine.

What do you think?