This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: sincos ( a little off-topic)
- From: Reimar Finken <rf227 at cam dot ac dot uk>
- To: Daniel Rohe <d dot rohe at fkf dot mpg dot de>
- Cc: gsl list <gsl-discuss at sources dot redhat dot com>
- Date: 27 May 2002 18:15:56 +0100
- Subject: Re: sincos ( a little off-topic)
- References: <3CF24CF5.3050502@fkf.mpg.de>
Hi Daniel,
Daniel Rohe <d.rohe@fkf.mpg.de> writes:
> I'm trying to use the sincos function which is supposed to be provided
> by libc. however all I get is the following compiler error:
>
> test_math.C: In function `int main()':
> test_math.C:26: implicit declaration of function `int sincos(...)'
>From the libc Manual:
==================================
Feature Test Macros
-------------------
The exact set of features available when you compile a source file
is controlled by which "feature test macros" you define.
[...]
You should define these macros by using `#define' preprocessor
directives at the top of your source code files. These directives
_must_ come before any `#include' of a system header file. It is best
to make them the very first thing in the file, preceded only by
comments. You could also use the `-D' option to GCC, but it's better
if you make the source files indicate their own meaning in a
self-contained way.
[...]
- Macro: _GNU_SOURCE
If you define this macro, everything is included: ISO C89,
ISO C99, POSIX.1, POSIX.2, BSD, SVID, X/Open, LFS, and GNU
extensions. In the cases where POSIX.1 conflicts with BSD, the
POSIX definitions take precedence.
=============================================
So the following works:
/home/reimar/test $ cat sincos.c
#define _GNU_SOURCE
#include <math.h>
#include <stdio.h>
int main (void)
{
double x = M_PI, s, c;
sincos (x, &s, &c);
printf ("%f %f %f\n", x, s, c);
return 0;
}
/home/reimar/test $ gcc -W -Wall -pedantic sincos.c -lm
/home/reimar/test $ ./a.out
3.141593 0.000000 -1.000000
/home/reimar/test $
Hope that helps,
Reimar