On Debian Sid (unstable) g++ was recently upgraded to version 4.7 and I
received the following error:
audioreader_portaudio.cpp: In member function ‘void AudioReaderPortAudio::stopReader()’:
audioreader_portaudio.cpp:143:22: error: ‘usleep’ was not declared in this scope
audioreader_portaudio.cpp:151:20: error: ‘sleep’ was not declared in this scope
audioreader_portaudio.cpp:164:20: error: ‘sleep’ was not declared in this scope
make[1]: *** [audioreader_portaudio.o] Error 1
I applied the following patch to audioreader_portaudio.cpp:
$ git diff
diff --git a/so2sdr/audioreader_portaudio.cpp
b/so2sdr/audioreader_portaudio.cpp
index 370020a..3aba4da 100644
--- a/so2sdr/audioreader_portaudio.cpp
+++ b/so2sdr/audioreader_portaudio.cpp
@@ -18,6 +18,11 @@
*/
#include <math.h>
#include "audioreader_portaudio.h"
+
+#ifdef Q_OS_LINUX
+#include <unistd.h>
+#endif
+
#ifdef Q_OS_WIN
#include <windows.h>
#include "pa_asio.h"
This will affect all recently released versions of SO2SDR, I would
think. I went looking for the reason and found it in the NEWS.gz file
installed by the Debian package (/usr/share/doc/g++-4.7/NEWS.gz) under
'Runtime Library (libstdc++):
- Avoid polluting the global namespace and do not include <unistd.h>.
So, the error makes perfect sense. Heh! This is now fixed in my Git
repository for my version 1.2.2git.
A bit more research shows that per the POSIX standard, usleep() is
considered obsolote. The C library offers nanosleep() in time.h but
there seem to be caveats regarding nanosleep() and threading. For now
usleep() is supported and probably will be for some time. Also,
winkey.cpp makes use of usleep() (seven times). As nanosleep() uses a
pair of structures for its passed values, and the structure typedef
contains a variable for whole seconds and nanoseconds, the call to
sleep() could be replaced as well. We would then be using a standard C
library call and not POSIX ones.
I did not have to specify unistd.h in winkey.cpp as it includes winkey.h
which includes qextserialport/qextserialport.h which then includes
unistd.h!
73, de Nate >>
--
"The optimist proclaims that we live in the best of all
possible worlds. The pessimist fears this is true."
Ham radio, Linux, bikes, and more:
http://www.n0nb.us