gcc 4.7 'sleep' was not declared in this scope

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
downer88 Offline
Junior Member
Posts: 1
Joined: Mar 2012
Reputation: 0
Post: #1
I couldn't log into bug tracker to submit this bug. I ran across this bug with new gcc 4.7 on Fedora:
Code:
make: Entering directory `/rpmbuild/BUILD/xbmc-11.0-Eden_beta1/tools/EventClients'
cd Clients/WiiRemote && \
/usr/bin/ccache g++ -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic -fPIC -I/usr/include/ffmpeg -D__STDC_CONSTANT_MACROS -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG=1 -fPIC CWIID_WiiRemote.cpp -lcwiid -lbluetooth -DICON_PATH="\"/usr/share/pixmaps/xbmc/\""  -o WiiRemote
CWIID_WiiRemote.cpp: In static member function 'static void CWiiRemote::MessageCallback(cwiid_wiimote_t*, int, cwiid_mesg*, timespec*)':
CWIID_WiiRemote.cpp:65:12: warning: enumeration value 'CWIID_MESG_BALANCE' not handled in switch [-Wswitch]
CWIID_WiiRemote.cpp:65:12: warning: enumeration value 'CWIID_MESG_MOTIONPLUS' not handled in switch [-Wswitch]
CWIID_WiiRemote.cpp: In function 'int main(int, char**)':
CWIID_WiiRemote.cpp:767:14: error: 'sleep' was not declared in this scope
make: *** [Clients/WiiRemote/WiiRemote] Error 1
make: Leaving directory `/rpmbuild/BUILD/xbmc-11.0-Eden_beta1/tools/EventClients'
error: Bad exit status from /var/tmp/rpm-tmp.x1hdIa (%install)

I'm not a programmer, but I added #include <unistd.h> to
/xbmc/tools/EventClients/Clients/WiiRemote/CWIID_WiiRemote.h
and it went away.
(From http://pubs.opengroup.org/onlinepubs/007...sleep.html )

Really nice program by the way!

I also still get this error with gcc 4.7 https://bugzilla.redhat.com/show_bug.cgi?id=805958 but it's from ffmpeg.
(This post was last modified: 2012-03-26 01:16 by downer88.)
find quote
spiff Offline
Retired Developer
Posts: 12,386
Joined: Nov 2003
Post: #2
your fix is correct. this tends to happen when we hop gcc versions as the include orders (in particular which header includes which) changes. in particular, gcc has moved towards being less and less forgiving, and have better split headers than it used to.
find quote