Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem calling exp10()

1,362 views
Skip to first unread message

Bruce McGoveran

unread,
Jul 12, 2011, 6:21:24 PM7/12/11
to
Hi. I repeatedly receive an "implicit declaration of function" error on the line on which I call exp10() in the following code:
/* A program to understand exponent calls better. */

#include <stdio.h>
#include <math.h>

int
main(void)
{
double e = exp10(10);
printf("%f\n", e);
return 0;
}

I wrote this code to try an isolate a similar error in another program. I've attempted to compile the code with make, and I can't. I've also tried adding the #define _GNU_SOURCE directive recommended in the man entry for exp10. That didn't help.

I would appreciate any help anyone can offer. Thank you.
--
comp.lang.c.moderated - moderation address: cl...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.

Keith Thompson

unread,
Jul 12, 2011, 10:24:44 PM7/12/11
to
Bruce McGoveran <bruce.m...@gmail.com> writes:
> Hi. I repeatedly receive an "implicit declaration of function" error
> on the line on which I call exp10() in the following code:
> /* A program to understand exponent calls better. */
>
> #include <stdio.h>
> #include <math.h>
>
> int
> main(void)
> {
> double e = exp10(10);
> printf("%f\n", e);
> return 0;
> }
>
> I wrote this code to try an isolate a similar error in another
> program. I've attempted to compile the code with make, and I can't.
> I've also tried adding the #define _GNU_SOURCE directive recommended
> in the man entry for exp10. That didn't help.
>
> I would appreciate any help anyone can offer. Thank you.

exp10 is a GNU extension, not a standard C library function.

Did you add the "#define _GNU_SOURCE" directive *above* the "#include
<math.h>" directive?

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

steve

unread,
Jul 12, 2011, 10:24:59 PM7/12/11
to
On Jul 12, 3:21 pm, Bruce McGoveran <bruce.mcgove...@gmail.com> wrote:
> Hi.  I repeatedly receive an "implicit declaration of function" error on the line on which I call exp10() in the following code:
>
> #include <stdio.h>
> #include <math.h>
>
> int
> main(void)
> {
>     double e = exp10(10);
>     printf("%f\n", e);
>     return 0;
>
> }
>
> --
> comp.lang.c.moderated - moderation address: c...@plethora.net -- you must

> have an appropriate newsgroups line in your header for your mail to be seen,
> or the newsgroup name in square brackets in the subject line.  Sorry.

I'm using LccWin32 and it seems to work without problem.


#include <stdio.h>
#include <math.h>

int main()
{
double e;
double x = 1.877665544;

e = exp10(x);
printf("%f\n",e); /* displays: 75.451094 */

return 0;
}

This sample from Lcc docs.

Bruce McGoveran

unread,
Jul 13, 2011, 2:14:43 PM7/13/11
to
Keith, thank you for the message. I did indeed do that, and at first, it didn't help. It turns out I hadn't put the #define directive first in the preprocessor directive list. When I did, everything compiled fine.

Many thanks.

Bruce
P.S. Great quote - Sir Arnold, no?

Jeremy Hall

unread,
Jul 13, 2011, 2:14:27 PM7/13/11
to
Its in glibc on Linux, but not in mingw

perhaps try: pow( 10, x )

Keith Thompson

unread,
Jul 13, 2011, 2:15:13 PM7/13/11
to
steve <blunt.a...@gmail.com> writes:
> On Jul 12, 3:21 pm, Bruce McGoveran <bruce.mcgove...@gmail.com> wrote:
>> Hi.  I repeatedly receive an "implicit declaration of function" error
>> on the line on which I call exp10() in the following code:
>>
>> #include <stdio.h>
>> #include <math.h>
>>
>> int
>> main(void)
>> {
>>     double e = exp10(10);
>>     printf("%f\n", e);
>>     return 0;
>>
>> }
>
> I'm using LccWin32 and it seems to work without problem.
>
>
> #include <stdio.h>
> #include <math.h>
>
> int main()
> {
> double e;
> double x = 1.877665544;
>
> e = exp10(x);
> printf("%f\n",e); /* displays: 75.451094 */
>
> return 0;
> }
>
> This sample from Lcc docs.

Apparently exp10() is both a GNU extension and an lcc-win32
extension. Both exp10()s probably do the same thing (except that the
lcc-win32 version probably doesn't require _GNU_SOURCE to use it).

Since exp10() is not standard C, presumably lcc-win32 would complain
about the call when invoked in a standard-conforming mode (I think
it's something like "-ansic").

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Barry Schwarz

unread,
Jul 14, 2011, 1:59:58 PM7/14/11
to
On Tue, 12 Jul 2011 17:21:24 -0500 (CDT), Bruce McGoveran
<bruce.m...@gmail.com> wrote:

>Hi. I repeatedly receive an "implicit declaration of function" error on the line on which I call exp10() in the following code:
>/* A program to understand exponent calls better. */

Maybe because math.h does not declare an exp10 function. In fact,
there is no standard function with that name. If your compiler
provides such a function as an extension, the documentation should
tell you where it is declared or how you activate the extension.

>
>#include <stdio.h>
>#include <math.h>
>
>int
>main(void)
>{
> double e = exp10(10);
> printf("%f\n", e);
> return 0;
>}
>
>I wrote this code to try an isolate a similar error in another program. I've attempted to compile the code with make, and I can't. I've also tried adding the #define _GNU_SOURCE directive recommended in the man entry for exp10. That didn't help.

This appears to be gnu problem. A group that discusses that compiler
may be a better source for you.

>
>I would appreciate any help anyone can offer. Thank you.

--
Remove del for email

steve

unread,
Jul 17, 2011, 11:48:39 PM7/17/11
to
On Jul 14, 10:59 am, Barry Schwarz <schwa...@dqel.com> wrote:
> Maybe because math.h does not declare an exp10 function.  In fact,
> there is no standard function with that name.  If your compiler
> provides such a function as an extension, the documentation should
> tell you where it is declared or how you activate the extension.

In LccWin32, exp10() is declared in math.h.

> --
> comp.lang.c.moderated - moderation address: c...@plethora.net -- you must

Hans-Bernhard Bröker

unread,
Jul 18, 2011, 7:08:16 PM7/18/11
to
On 18.07.2011 05:48, steve wrote:

> In LccWin32, exp10() is declared in math.h.

You appear to be assuming that this fact were of any relevance to the
discussion at hand. It isn't.

0 new messages