l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2004 Sep 30 23:39

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] compiler error causing me great sadness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] compiler error causing me great sadness


Thank you (again!) for such a wonderful response.  This email is a gem.

On Wed 29 Sep 04, 10:27 PM, Ken Herron <kherron+lugod@fmailbox.com> said:
> --On Wednesday, September 29, 2004 11:06:50 PM -0400 Peter Jay Salzman 
> <p@dirac.org> wrote:
> >   #ifndef _FSIGNAL_H_
> >   #define _FSIGNAL_H_
> >
> >   #define __GNU_SOURCE
> >   #include <signal.h>
> >   #include <stdio.h>
> I think you want _GNU_SOURCE there, not __GNU_SOURCE. Though "#define 
> _POSIX_C_SOURCE 199309L" should be adequate.
> >It's kind of a mess, but when I include __USE_POSIX and
> >__USE_POSIX199309, I get "constant redefinition" errors.  So instead, I
> >add:
> You aren't supposed to define the __USE_* macros yourself. See 
> <features.h>. Actually, when I ran your fsignal.h through "gcc -E" the 
> postprocessed C contained the siginfo_t definition. If you're not getting 
> it, then perhaps you've set one of the standard-selection macros to an 
> old standard such that __USE_POSIX199309 isn't supposed to be defined.

Thanks for telling me this.  I didn't know anything about __USE_* macros
until I started grunging around in system header files, and noticed they
seemed to pull in what I wanted.

But the features.h header you mentioned is a _great_ resource.  Thanks for
pointing it out!
> >How am I supposed to figure out how to get a definition for siginfo_t?
> >Am I really supposed to grub around in the libc header files???
> No, of course not. There are standards for this stuff, though programming 
> books don't always do a good job of explaining them. For example, on a 
> modern system running:
> 	echo '#include <signal.h>' | gcc -E -
> should get you a copy of the siginfo_t definition, but:
> 	echo '#include <signal.h>' | gcc -E -D_POSIX_SOURCE -
> because _POSIX_SOURCE implies a specific revision of the POSIX standard 
> that predates the siginfo_t type.

This is a really nice trick to have in my bag of tricks!  Again, thanks for
showing this to me!

Interestingly, this compiled whether _GNU_SOURCE was defined in fsignal.h or


   #ifndef _FSIGNAL_H_
   #define _FSIGNAL_H_

   #include <stdio.h>
   #include <signal.h>

   void fpe_trap_enable(void);
   void fpe_print_cause(FILE *file, siginfo_t *info);
   void fpe_callback(int sig_number, siginfo_t *info, void *data);
   void int_callback(int sig_number);
   void Initialize_Signals(void);



   #define _GNU_SOURCE       <------   this was the key
   #include "fsignal.h"

   int main(void)

      return 0;

The program compiles just fine, even when I don't define _GNU_SOURCE in

The key is that _GNU_SOURCE needs to be defined in each .c file that includes
fsignal.h, but not fsignal.h itself (although putting it in fsignal.h doesn't
HURT anything.  It just doesn't do much good).

So, my next question --- when #defining things for the sake of pulling in
definitions from headers, is it a general rule that you put the #defines in
the .c files and not the .h files?

It looks true in this case.

If someone wants to play with the code to verify, I can send a tar.bz2 file.


Make everything as simple as possible, but no simpler. -- Albert Einstein
GPG Instructions: http://www.dirac.org/linux/gpg
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.