We are catching compiler errors when using sigemptyset
on Cygwin under Newlib. The error occurs with a C++ compiler, but only when -std=XXX
is used. Without a standard option, the test program compiles and executes as expected.
The test program is below, and the Cygwin header of interest follows. I don't see anything suspicious in the Cygwin header.
I've tried tricks like #define _GNU_SOURCE
and #define _XOPEN_SOURCE 700
. I've also tried tricks like using the global and std
namespaces. Related, see What does -D_XOPEN_SOURCE do/mean? and Namespace issues in c++11?.
What is causing the compile failure and how do I fix it?
$ cat ~/test.cxx
#include <signal.h>
int main(int argc, char* argv[])
{
struct sigaction new_handler;
return sigemptyset(&new_handler.sa_mask);
}
Without a -std=XXX
, it results in:
$ g++ -c test.cxx
$
With a -std=XXX
, it results in:
$ g++ -std=c++03 -c test.cxx
test.cxx: In function int main(int, char**):
test.cxx:6:44: error: sigemptyset was not declared in this scope
return sigemptyset(&new_handler.sa_mask);
And when trying to use sigemptyset
in the global namespace:
$ g++ -std=c++03 -c test.cxx
test.cxx: In function ‘int main(int, char**)’:
test.cxx:6:12: error: ‘::sigemptyset’ has not been declared
return ::sigemptyset(&new_handler.sa_mask);
^
_XOPEN_SOURCE
before including<signal.h>
. – Shiism<cygwin/signal.h>
for the Cygwin signal header file. – Shiismsigemptyset
there are two hits: (1)/usr/include/bash/sig.h
and (2)/usr/include/sys/signal.h
. – Rackety<cygwin/signal.h>
directly, instead it's a file you need to look at for Cygwin-specific things. Like for example what macros are needed to be defined before you include<signal.h>
. – Shiism