lcm-proj / lcm

Lightweight Communications and Marshalling
GNU Lesser General Public License v2.1
944 stars 385 forks source link

implicit-function-declaration error during build #498

Closed yuzibo closed 3 months ago

yuzibo commented 3 months ago

Hi, There is one build issue from Debian

map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -c -o emit_csharp.o emit_csharp.c
> emit_cpp.c: In function ‘emit_header_start’:
> emit_cpp.c:306:19: error: implicit declaration of function ‘_exit’ [-Werror=implicit-function-declaration]
>   306 |                   _exit(1);
>       |                   ^~~~~
> emit_cpp.c:306:19: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]
> In function ‘ensure_token_capacity’,
>     inlined from ‘tokenize_next_internal’ at tokenize.c:325:14:
> tokenize.c:127:28: warning: argument 2 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
>   127 |         t->token = (char*) realloc(t->token, t->token_capacity);
>       |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from tokenize.c:1:
> /usr/include/stdlib.h: In function ‘tokenize_next_internal’:
> /usr/include/stdlib.h:564:14: note: in a call to allocation function ‘realloc’ declared here
>   564 | extern void *realloc (void *__ptr, size_t __size)
yuzibo commented 3 months ago

And I have one patch and it seems it can be built with it:

--- a/lcm-logger/lcm_logger.c
+++ b/lcm-logger/lcm_logger.c
@@ -8,6 +8,7 @@

 #include <glib.h>
 #include <glib/gstdio.h>
+#include <unistd.h>

 #include <lcm/lcm.h>

--- a/lcmgen/emit_cpp.c
+++ b/lcmgen/emit_cpp.c
@@ -11,6 +11,7 @@

 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>

 #include "lcmgen.h"
yuzibo commented 3 months ago

New version has patched this, so close this. Sorry for the noisy.