public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* sincos ( a little off-topic)
  2002-12-31  9:55 sincos ( a little off-topic) Daniel Rohe
@ 2002-05-27  9:45 ` Daniel Rohe
  2002-12-31  9:55 ` Reimar Finken
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Rohe @ 2002-05-27  9:45 UTC (permalink / raw)
  To: gsl list

this questionis not directly gsl-specific, but it may interest some of 
you, and I couldn't find an answer anywhere else.

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(...)'

I had a look at math.h and there's a strange construct which declares
sincos only if some macro is defined.

does anyone know how to access this function, and maybe also if its
preformance is reasonable?

thanks in advance,

daniel

-- 
Daniel Rohe
Max Planck Institute for Solid State Research
Heisenbergstr. 1, D-70569 Stuttgart
Phone: +49 711/689-1516
Fax:   +49 711/689-1702



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sincos ( a little off-topic)
  2002-12-31  9:55 ` Reimar Finken
@ 2002-05-28  2:27   ` Reimar Finken
  0 siblings, 0 replies; 4+ messages in thread
From: Reimar Finken @ 2002-05-28  2:27 UTC (permalink / raw)
  To: Daniel Rohe; +Cc: gsl list

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* sincos ( a little off-topic)
@ 2002-12-31  9:55 Daniel Rohe
  2002-05-27  9:45 ` Daniel Rohe
  2002-12-31  9:55 ` Reimar Finken
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Rohe @ 2002-12-31  9:55 UTC (permalink / raw)
  To: gsl list

this questionis not directly gsl-specific, but it may interest some of 
you, and I couldn't find an answer anywhere else.

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(...)'

I had a look at math.h and there's a strange construct which declares
sincos only if some macro is defined.

does anyone know how to access this function, and maybe also if its
preformance is reasonable?

thanks in advance,

daniel

-- 
Daniel Rohe
Max Planck Institute for Solid State Research
Heisenbergstr. 1, D-70569 Stuttgart
Phone: +49 711/689-1516
Fax:   +49 711/689-1702



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sincos ( a little off-topic)
  2002-12-31  9:55 sincos ( a little off-topic) Daniel Rohe
  2002-05-27  9:45 ` Daniel Rohe
@ 2002-12-31  9:55 ` Reimar Finken
  2002-05-28  2:27   ` Reimar Finken
  1 sibling, 1 reply; 4+ messages in thread
From: Reimar Finken @ 2002-12-31  9:55 UTC (permalink / raw)
  To: Daniel Rohe; +Cc: gsl list

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-27 17:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-31  9:55 sincos ( a little off-topic) Daniel Rohe
2002-05-27  9:45 ` Daniel Rohe
2002-12-31  9:55 ` Reimar Finken
2002-05-28  2:27   ` Reimar Finken

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).