public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc compiler, version egcs 1.1.1
@ 2000-05-13  7:35 Henry Abrecht
  2000-05-13 13:43 ` Martin v. Loewis
  0 siblings, 1 reply; 2+ messages in thread
From: Henry Abrecht @ 2000-05-13  7:35 UTC (permalink / raw)
  To: help-gcc

Hello,

I have what I believe is version 2.8.1 of your c compiler--or is it
> egcs-1.1.1? I got that number from the man notes on gcc. My platform is Caldera OpenLinux 2.2. 

  My problem: I'm trying to declare and call math
> functions--specifically sin(x), cos(x), sqrt(x), pow(x, y).
> When I call them and include math.h (or is it tgmath.h?) I get
the
> message: "function undefined." When I declare them (ex: double
> sqrt(double)) I get the same message.
> 
> My question: What's the correct prototype format for these
functions?
> (or more generally, how are they declared and called?) If it
helps, I'm
> using a book called "A Book on C," by Al Kelley and Ira Pohl. On
his Web
> site Pohl indicates that libraries used by c compilers might have
changed
> since he wrote his book. He recommends that users contact the compiler maker for the correct function prototypes. (Pohl's book is based on GCC 2.7.)

Thanks,
Henry Abrecht

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

* Re: gcc compiler, version egcs 1.1.1
  2000-05-13  7:35 gcc compiler, version egcs 1.1.1 Henry Abrecht
@ 2000-05-13 13:43 ` Martin v. Loewis
  0 siblings, 0 replies; 2+ messages in thread
From: Martin v. Loewis @ 2000-05-13 13:43 UTC (permalink / raw)
  To: jalright; +Cc: help-gcc

>   My problem: I'm trying to declare and call math
> functions--specifically sin(x), cos(x), sqrt(x), pow(x, y).  When I
> call them and include math.h (or is it tgmath.h?) I get the message:
> "function undefined." When I declare them (ex: double sqrt(double))
> I get the same message.

I doubt that the message you get literally reads "function
undefined". It is very important that you quote error message
literally as they appear on the terminal.

> My question: What's the correct prototype format for these
> functions? (or more generally, how are they declared and called?)

You should never declare the functions yourself; instead, use the
appropriate header file. For sin/cos/sqrt/pow, the header file is
indeed math.h, so there is no need to declare the functions further.

I believe your problem is not that the functions where not declared,
but that no implementation was found, i.e. that the error message read

undefined reference to `sin'

In that case, you should tell the compiler to link with the math
library, i.e. you need to add -lm.

Regards,
Martin

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

end of thread, other threads:[~2000-05-13 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-13  7:35 gcc compiler, version egcs 1.1.1 Henry Abrecht
2000-05-13 13:43 ` Martin v. Loewis

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