By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

sigset_t and gcc

P: n/a
Can anybody tell me what is wrong with the following code?
It compiles ok with 'gcc file.c',
but not 'gcc -ansi file.c' or 'gcc -std=c99 file.c'.
It complains that 'sigset_t' is undeclared.
What options am I missing? Thanks

#include <signal.h>

int main()
{
sigset_t set;
}
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jade Fox wrote:
Can anybody tell me what is wrong with the following code?
It compiles ok with 'gcc file.c',
but not 'gcc -ansi file.c' or 'gcc -std=c99 file.c'.
It complains that 'sigset_t' is undeclared.
What options am I missing? Thanks

#include <signal.h>

int main()
{
sigset_t set;
}


I'd hypothesise that sigset_t is not in the ISO standards for C.

<fx:peek/>

Can't see it in C90.

Perhaps it's POSIX.

--
Chris "electric hedgehog" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgrou...mp.lang.c.html
C welcome: http://www.angelfire.com/ms3/bchambl...me_to_clc.html
Nov 13 '05 #2

P: n/a
cj****@eden.rutgers.edu (Jade Fox) wrote:
Can anybody tell me what is wrong with the following code?
It compiles ok with 'gcc file.c',
but not 'gcc -ansi file.c' or 'gcc -std=c99 file.c'.
So it compiles in use-every-GNU-extension-you-can-find mode, but not in
ISO mode. Gosh, what _would_ be the problem?
It complains that 'sigset_t' is undeclared.
What options am I missing? Thanks


None. You're missing the fact that there is no such thing as sigset_t in
the Standard.

Richard
Nov 13 '05 #3

P: n/a
Chris Dollin <ke**@hpl.hp.com> wrote:
Jade Fox wrote:
Can anybody tell me what is wrong with the following code?
It compiles ok with 'gcc file.c',
but not 'gcc -ansi file.c' or 'gcc -std=c99 file.c'.
It complains that 'sigset_t' is undeclared.
What options am I missing? Thanks
[OT]
By specifying -ansi or -std=c89 or std=c99 you told gcc that you
only want to use those language features that are defined in the
corresponding standards. sigset_t isn't among those features.
[/OT]
#include <signal.h>

int main()
{
sigset_t set;
}


I'd hypothesise that sigset_t is not in the ISO standards for C.

<fx:peek/>

Can't see it in C90.


And it's not mentioned in C99 either.

Regards
--
Irrwahn
(ir*******@freenet.de)
Nov 13 '05 #4

P: n/a
cj****@eden.rutgers.edu (Jade Fox) wrote:
Can anybody tell me what is wrong with the following code?
It compiles ok with 'gcc file.c',
but not 'gcc -ansi file.c' or 'gcc -std=c99 file.c'.
It complains that 'sigset_t' is undeclared.
What options am I missing? Thanks

#include <signal.h>

int main()
{
sigset_t set;
}


The compiler is telling you sigset_t is not defined by the C
Standard, which also makes it off topic in this particular
newsgroup. The appropriate place to ask would be a group
specific to programming on your particular platform.

However...

It is a POSIX defined type (as opposed to a C99 type), and if
you put "#define _POSIX_SOURCE" at the top of your source file
it will likely have the desired effect.

A wild guess... but you might try looking in
/usr/include/signal.h where you'll probably note that it
includes <features.h>, which is a file you'll want to explore.
As soon as you are confused enough to *really* need help, go
find that platform specific group. :-)

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) fl***@barrow.com
Nov 13 '05 #5

P: n/a
In <cb**************************@posting.google.com > cj****@eden.rutgers.edu (Jade Fox) writes:
Can anybody tell me what is wrong with the following code?
It compiles ok with 'gcc file.c',
but not 'gcc -ansi file.c' or 'gcc -std=c99 file.c'.
It complains that 'sigset_t' is undeclared.
What options am I missing? Thanks

#include <signal.h>

int main()
{
sigset_t set;
}


Here's the full story. When the implementation is used in conforming
mode (which is partly achieved by gcc's options -ansi or -std=c99), the
standard headers are not allowed to declare/define *any* identifier in
the program name space that is not specified by the corresponding section
in the relevant standard (C89 for -ansi, C99 for -std=c99). Or neither
of these standards specifies sigset_t in the section dedicated to
<signal.h>, therefore this header is NOT allowed to declare/define this
identifier when included in *conforming* mode.

There are no such restrictions when the header is included in
non-conforming mode (there are no restrictions at all in this case),
so you'll get the definition of sigset_t if you use neither -ansi
nor any -std= option.

You have to opt between using non-standard features and invoking the
compiler in standard conforming mode, because you can't have both at the
same time. Be warned, however, that gcc is not a C compiler in its
default mode, it is a GNU C compiler. Certain invalid C programming
constructs are valid in GNU C. To get warnings for at least a subset
of them, use the -pedantic option (which is required as a companion
to -ansi or -std= to invoke the compiler in standard conforming
mode, too). -pedantic doesn't remove any declarations/definitions from
the included headers.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.