Bug 101192

Summary: libbsd 0.8.3 / Git HEAD: /usr/include/bsd/stdlib.h:52:27: error: unknown type name ‘u_char’ with -std=c89
Product: libbsd Reporter: Sebastian Pipping <webmaster>
Component: libbsdAssignee: Guillem Jover <guillem>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Sebastian Pipping 2017-05-25 17:58:40 UTC
Hi!


I'm running GCC 4.9.3 on 64bit Linux with glibc 2.24 here.  I have

  #include <bsd/stdlib.h>

in my code and get this compile error:

  /usr/include/bsd/stdlib.h:52:27: error: unknown type name ‘u_char’
   void arc4random_addrandom(u_char *dat, int datlen);

It seems I would need to have something like

 #define __USE_MISC
 #include <sys/types.h>

on my end even prior to that include to get u_char known but it doesn't seem to work well and I would also expect that header bsd/stdlib.h pulls everything it needs by itself.


According to [1], Debian has addressed this problem downstream in the past like this:

  "Fix arc4random prototypes from uchar to unsigned char."

Looking at the latest libbsd tarball and the Git repository, that change has not gone into an release yet, it seems.  It would be great to get this fixed upstream.  Please let me know what you think.

Thanks and best



Sebastian


[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719640
Comment 1 Sebastian Pipping 2017-05-29 23:52:28 UTC
Update: 

* I was mis-reading that Debian bug report.  They didn't patch it.

* The bug needs -std=c89 to trigger, -std=gnu89 seems to work fine.

It would be awesome if "u_char" could be patched into "unsigned char" for c89.
Comment 2 Guillem Jover 2017-06-06 02:15:37 UTC
Hmmm, indeed, it seems I had some of the changes around but those didn't end up on a release. :/ Thanks for reporting. I've fixed this now locally and will push for the next release 0.9.0.
Comment 3 Guillem Jover 2017-06-19 02:45:40 UTC
This should be fixed now in lbibsd 0.8.4. Closing.
Comment 4 Sebastian Pipping 2017-06-21 18:30:17 UTC
Seems to work well now, thank you!


# gcc -std=c89 -Wall -Wextra -pedantic main.c 

# cat main.c 
#include <bsd/stdlib.h>
int main() { return 0 ; }

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.