signal.h: sa_handler not usable when compiling with `gcc -ansi'
Anschuetz, Andreas
aanschuetz@ingenico.de
Fri Jun 24 10:21:00 GMT 2005
cygwin: cygwin-1.5.17-1
Win OS tested: Windows 2000
The sa_handler entry of the sigaction structure is not accessible
when I compile with `gcc -ansi' (Makefile and example `signal-test.c'
attached):
gcc -ansi -o signal-ansi signal.c
signal.c: In function `main':
signal.c:13: error: structure has no member named `sa_handler'
The following line caused the error:
sa_on.sa_handler = sighandler;
The same program is compilable with `gcc -std=gnu89'. I assume that
the anonymous union in `struct sigaction' in /usr/include/cygwin/signal.h
is not iso9899:1990 conform.
Is compiling with the `-ansi' option not supported by cygwin or is this
a bug?
In case of it is a bug in cygwin I've also included an example patch
which fixes the problem, the code which fixes the problem is taken from
/usr/include/signal.h.
Regards,
Andreas Anschuetz
-------------- next part --------------
--- signal.h.orig 2005-06-23 20:42:25.828859000 +0200
+++ signal.h 2005-06-23 20:58:53.769448000 +0200
@@ -150,11 +150,16 @@
{
_sig_func_ptr sa_handler; /* SIG_DFL, SIG_IGN, or pointer to a function */
void (*sa_sigaction) ( int, siginfo_t *, void * );
- };
+ } _signal_handlers;
sigset_t sa_mask;
int sa_flags;
};
+#define sa_handler _signal_handlers.sa_handler
+#if defined(_POSIX_REALTIME_SIGNALS)
+#define sa_sigaction _signal_handlers.sa_sigaction
+#endif
+
#define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children
stop */
#define SA_SIGINFO 2 /* Invoke the signal catching function
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signal-test.c
Type: text/x-csrc
Size: 249 bytes
Desc:
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20050624/082e0165/attachment.bin>
-------------- next part --------------
signal-ansi:
gcc -ansi -o signal-ansi signal-test.c
signal-gnu89:
gcc -std=gnu89 -o signal-gnu89 signal-test.c
More information about the Cygwin-patches
mailing list