Problem upgrading libpci ... stdlib.h errors

I am attempting to upgrade devel/libpci on a FreeBSD-9.1-RELEASE amd64 system. I receive the following errors in /usr/include/stdlib.h when gmake attempts to compile init.c:
Code:
root:/usr/ports/devel/libpci# make install clean
===>  Building for libpci-3.2.0
gmake -C lib all
gmake[1]: Entering directory `/usr/ports/devel/libpci/work/pciutils-3.2.0/lib'
cc -O2 -pipe -fno-strict-aliasing -fPIC -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -I/usr/src/sys   -c -o init.o init.c
In file included from init.c:10:
/usr/include/stdlib.h:54: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wchar_t'
/usr/include/stdlib.h:99: error: expected ')' before '*' token
/usr/include/stdlib.h:100: error: expected ')' before '*' token
/usr/include/stdlib.h:114: error: expected declaration specifiers or '...' before 'wchar_t'
/usr/include/stdlib.h:115: error: expected ';', ',' or ')' before '*' token
gmake[1]: *** [init.o] Error 1
gmake[1]: Leaving directory `/usr/ports/devel/libpci/work/pciutils-3.2.0/lib'

The date on /usr/include/stdlib.h is Dec 4, so it has not been modified since the original installation of FreeBSD.

Anyone have any idea why a header file that has not changed is suddenly generating compile errors?
 
For me compiles well on FreeBSD-9.1-RELEASE-p2/i386, note that,
Code:
typedef __wchar_t       wchar_t;
is defined/declared in stdlib.h file:
Code:
#ifndef __cplusplus
#ifndef _WCHAR_T_DECLARED
typedef __wchar_t       wchar_t;
#define _WCHAR_T_DECLARED
#endif
#endif

In gcc(1), the error
Code:
/usr/include/stdlib.h:54: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wchar_t'
is almost always associated with an typedef that isn't in scope when you use it. Maybe you have a corrupted header file, so reinstall /usr/src will do the trick.
 
The header file /usr/include/stdlib.h hasn't changed but some other header file that is included before it in the source has changed and possibly uses a macro that rewrites parts of /usr/include/stdlib.h. This is a very common problem in C and a good example why macros should be avoided as much as possible.
 
Thanks to both @cpu82 and @kpa. If I had not let my C programming skills lapse, I would have remembered the macro issue. Used to run into it all the time back in the day.

Also, my analysis of the problem was compounded in that I was tracking -CURRENT in /usr/src for a while, but stopped.

It's all good now.
 
Last edited by a moderator:
I believe I'm having a similar problem but I have no programming experience so I don't know what to do:

Code:
/usr/include/runetype.h:92: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'const'
/usr/include/runetype.h: In function '__getCurrentRuneLocale':
/usr/include/runetype.h:96: error: '_ThreadRuneLocale' undeclared (first use in this function)
/usr/include/runetype.h:96: error: (Each undeclared identifier is reported only once
/usr/include/runetype.h:96: error: for each function it appears in.)
init.c: In function 'pci_generic_error':
init.c:97: warning: implicit declaration of function 'exit'
init.c:97: warning: incompatible implicit declaration of built-in function 'exit'

gmake[1[]: *** [init.o] Error 1
In file included from access.c:10:
/usr/include/stdlib.h:82: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'gmake[1]:
/usr/include/stdlib.h:151: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'gmake[1]:
gmake[1]: *** [dump.o] Error 1
gmake[1]: *** [access.o] Error 1
gmake[1]: Leaving directory '/usr/ports/devel/libpci/work/pciutils-3.2.0/lib'
gmake: ***[lib/libpci.a] Error 2

I'm trying to build Chromium. What should I do?
 
I'm running a brand new install of 9.1-RELEASE. I also just got the kernel source from SVN. I've built X11 and nVidia drivers and that's it.
 
Back
Top