Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: use of undeclared identifier 'size_t'; did you mean 'sizeof'? #410

Closed
yurivict opened this issue Aug 11, 2021 · 5 comments
Closed

Comments

@yurivict
Copy link

/disk-samsung/freebsd-ports/science/siconos/work/siconos-4.4.0.rc3/numerics/src/tools/GAMSlink.c:11:3: error: use of undeclared identifier 'size_t'; did you mean 'sizeof'?
  size_t len = strlen(src) + 1;
  ^~~~~~
  sizeof
/disk-samsung/freebsd-ports/science/siconos/work/siconos-4.4.0.rc3/numerics/src/tools/GAMSlink.c:11:10: error: use of undeclared identifier 'len'
  size_t len = strlen(src) + 1;
         ^
/disk-samsung/freebsd-ports/science/siconos/work/siconos-4.4.0.rc3/numerics/src/tools/GAMSlink.c:11:16: warning: implicitly declaring library function 'strlen' with type 'unsigned long (const char *)' [-Wimplicit-function-declaration]
  size_t len = strlen(src) + 1;
               ^
/disk-samsung/freebsd-ports/science/siconos/work/siconos-4.4.0.rc3/numerics/src/tools/GAMSlink.c:11:16: note: include the header <string.h> or explicitly provide a declaration for 'strlen'
/disk-samsung/freebsd-ports/science/siconos/work/siconos-4.4.0.rc3/numerics/src/tools/GAMSlink.c:12:23: warning: implicitly declaring library function 'malloc' with type 'void *(unsigned long)' [-Wimplicit-function-declaration]
  char* dest = (char*)malloc(len * sizeof(char));
                      ^

Version 4.4.0.rc3
clang-11
FreeBSD 13

@xhub
Copy link
Member

xhub commented Aug 12, 2021

Thanks for the report and also porting siconos to FreeBSD!

I have a tentative fix in the CI pipeline that fixes the missing include as well as the logic for detecting the presence of strdup.
The libc on FreeBSD does provide this function.

@yurivict
Copy link
Author

FYI, this patch solved it in the port:

--- numerics/src/tools/GAMSlink.c.orig  2021-08-11 22:15:55 UTC
+++ numerics/src/tools/GAMSlink.c
@@ -1,5 +1,6 @@
 /* GAMS stuff */
 
+#if 0
 #define _XOPEN_SOURCE 700
 
 #if (__linux ||  __APPLE__)
@@ -14,6 +15,7 @@ static inline char* strdup(const char* src)
   return dest;
 }
 #endif
+#endif
 #include "SiconosConfig.h" // for HAVE_GAMS_C_API
 #include <math.h>
 #ifdef HAVE_GAMS_C_API

@xhub
Copy link
Member

xhub commented Aug 12, 2021

The fix rather changes the #if (__linux || __APPLE__) condition to include the *BSD and also moves the requires includes up in case the libc does not provide strdup (which must be pretty rare those days).

Since FreeBSD does provide strdup in essence your patch is functionally equivalent to the fix.

siconos-team pushed a commit that referenced this issue Aug 18, 2021
[numerics] fix missing includes and strdup detection for *BSD

See merge request nonsmooth/siconos!18
@xhub
Copy link
Member

xhub commented Aug 25, 2021

This should be fixed in 05b48fd. Many thanks for your packaging efforts!

@xhub xhub closed this as completed Aug 25, 2021
@yurivict
Copy link
Author

You are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants