473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

function declaration nested?

Ive been away from programming for a few years and am having difficulty
accessing a function from a math/engineering library that I want to use .
I thought that double foo(double); inserted in the calling routine would
let me say x=foo(y); But I get a warning from the compilation that says
"warning: nested extern declaration of 'foo'. Thanks for any suggestions

Nov 13 '05 #1
10 15008
"Phil Reardon" <pc**@pcrt.com> writes:
Ive been away from programming for a few years and am having difficulty
accessing a function from a math/engineering library that I want to use .
I thought that double foo(double); inserted in the calling routine would
let me say x=foo(y); But I get a warning from the compilation that says
"warning: nested extern declaration of 'foo'. Thanks for any suggestions


Please post the minimum compileable (or compile-attemptable) code
that exhibits the problem you are experiencing; until you do that
we can only talk about our suspicions, not point out what we know
to be the problem. "Inserted in the calling routine?"

If you mean you did something like:

void my_name_is_of_no_consequence(void)
{
double foo(double);

x=foo(y);
}

And you got that warning; well, an implementation is within its
rights to complain about anything it wants to. It may be that the
implementation "thinks" that you might have meant to declare
foo() at file-scope, I dunno. As long as it compiles, there isn't
really a problem in this case.

HTH,
Micah
Nov 13 '05 #2
Phil Reardon writes:
Ive been away from programming for a few years and am having difficulty
accessing a function from a math/engineering library that I want to use .
I thought that double foo(double); inserted in the calling routine would
let me say x=foo(y); But I get a warning from the compilation that says
"warning: nested extern declaration of 'foo'. Thanks for any suggestions


C does not allow nesting of functions, a la Pascal. It may be that what you
want is a *pointer to* a function. That comes up commonly in mathematics.
and C has provisions for that.
Nov 13 '05 #3
[...]
C does not allow nesting of functions, a la Pascal. It may be that what you want is a *pointer to* a function. That comes up commonly in mathematics.
and C has provisions for that.


http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_5.html

see nested functions

i couldnt figure out whether this feature refers to gcc-extensions or
to C99 extentions ..

can you say for sure it's not in C99?

thx

--
Daniel


Nov 13 '05 #4
Daniel Schüle writes:
C does not allow nesting of functions, a la Pascal. It may be that what

you
want is a *pointer to* a function. That comes up commonly in mathematics. and C has provisions for that.


http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_5.html

see nested functions

i couldnt figure out whether this feature refers to gcc-extensions or
to C99 extentions ..

can you say for sure it's not in C99?


No, I can't say for sure, I am not a language maven. But the start of the
paragraph you refer to says:
"GNU C provides several language features not found in ISO standard
C."

Which tells me that *this* is a GNU C extension. I also think it is highly
unlikely that they would start nesting at this point in time.
---
Just scanning the list of GNU extensions supports the pedantic set's
insistence on limiting the newsgroup to standard C. There's an *awful lot*
of stuff there! So much that if I were using GNU I might be tempted to
abandon this newsgroup in favor of a GNU newsgroup.
Nov 13 '05 #5
"osmium" <r1********@comcast.net> wrote in
news:bm************@ID-179017.news.uni-berlin.de on Sat 11 Oct 2003
11:22:46a:

So much that if I were using GNU I might be
tempted to abandon this newsgroup in favor of a GNU newsgroup.


Please, do. At least as long as you wish to discuss nonstandard extensions
to C.

Nov 13 '05 #6
August Derleth <li*****************@onewest.net> wrote:
"osmium" <r1********@comcast.net> wrote in
news:bm************@ID-179017.news.uni-berlin.de on Sat 11 Oct 2003
11:22:46a:

So much that if I were using GNU I might be
tempted to abandon this newsgroup in favor of a GNU newsgroup.


Please, do. At least as long as you wish to discuss nonstandard extensions
to C.


C'mon, he said /if/, and he didn't discuss nonstandard extensions; the
question was, if a certain feature was (topical) ISO-C or (OT) GNU.

Regards
--
Irrwahn
(ir*******@freenet.de)
Nov 13 '05 #7
In <m3************@localhost.localdomain> Micah Cowan <mi***@cowan.name> writes:
"Phil Reardon" <pc**@pcrt.com> writes:
Ive been away from programming for a few years and am having difficulty
accessing a function from a math/engineering library that I want to use .
I thought that double foo(double); inserted in the calling routine would
let me say x=foo(y); But I get a warning from the compilation that says
"warning: nested extern declaration of 'foo'. Thanks for any suggestions


Please post the minimum compileable (or compile-attemptable) code
that exhibits the problem you are experiencing; until you do that
we can only talk about our suspicions, not point out what we know
to be the problem. "Inserted in the calling routine?"

If you mean you did something like:

void my_name_is_of_no_consequence(void)
{
double foo(double);

x=foo(y);
}

And you got that warning; well, an implementation is within its
rights to complain about anything it wants to. It may be that the
implementation "thinks" that you might have meant to declare
foo() at file-scope, I dunno. As long as it compiles, there isn't
really a problem in this case.


I suspect he's including a header that already provides a declaration
for foo().

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #8
In <bm************@ID-179017.news.uni-berlin.de> "osmium" <r1********@comcast.net> writes:
Phil Reardon writes:
Ive been away from programming for a few years and am having difficulty
accessing a function from a math/engineering library that I want to use .
I thought that double foo(double); inserted in the calling routine would
let me say x=foo(y); But I get a warning from the compilation that says
"warning: nested extern declaration of 'foo'. Thanks for any suggestions


C does not allow nesting of functions, a la Pascal.


The diagnostic is about a nested function declaration, not about a nested
function definition. Probably something like:

#include <math.h>

int main()
{
double sin(double);
return 0;
}

would trigger the same diagnostic. If this is the case, indeed, all the
OP has to do is to drop the declaration of foo inside the calling function
because foo is already declared. He may also want to check that the
declaration that is already in scope is the one he expects.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #9
Da*****@cern.ch (Dan Pop) writes:
In <m3************@localhost.localdomain> Micah Cowan <mi***@cowan.name> writes:
"Phil Reardon" <pc**@pcrt.com> writes:
Ive been away from programming for a few years and am having difficulty
accessing a function from a math/engineering library that I want to use .
I thought that double foo(double); inserted in the calling routine would
let me say x=foo(y); But I get a warning from the compilation that says
"warning: nested extern declaration of 'foo'. Thanks for any suggestions


Please post the minimum compileable (or compile-attemptable) code
that exhibits the problem you are experiencing; until you do that
we can only talk about our suspicions, not point out what we know
to be the problem. "Inserted in the calling routine?"

If you mean you did something like:

void my_name_is_of_no_consequence(void)
{
double foo(double);

x=foo(y);
}

And you got that warning; well, an implementation is within its
rights to complain about anything it wants to. It may be that the
implementation "thinks" that you might have meant to declare
foo() at file-scope, I dunno. As long as it compiles, there isn't
really a problem in this case.


I suspect he's including a header that already provides a declaration
for foo().


But then what did he mean by "inserted in the calling routine?"

-Micah
Nov 13 '05 #10
In <m3************@localhost.localdomain> Micah Cowan <mi***@cowan.name> writes:
Da*****@cern.ch (Dan Pop) writes:
In <m3************@localhost.localdomain> Micah Cowan <mi***@cowan.name> writes:
>"Phil Reardon" <pc**@pcrt.com> writes:
>
>> Ive been away from programming for a few years and am having difficulty
>> accessing a function from a math/engineering library that I want to use .
>> I thought that double foo(double); inserted in the calling routine would
>> let me say x=foo(y); But I get a warning from the compilation that says
>> "warning: nested extern declaration of 'foo'. Thanks for any suggestions
>
>Please post the minimum compileable (or compile-attemptable) code
>that exhibits the problem you are experiencing; until you do that
>we can only talk about our suspicions, not point out what we know
>to be the problem. "Inserted in the calling routine?"
>
>If you mean you did something like:
>
> void my_name_is_of_no_consequence(void)
> {
> double foo(double);
>
> x=foo(y);
> }
>
>And you got that warning; well, an implementation is within its
>rights to complain about anything it wants to. It may be that the
>implementation "thinks" that you might have meant to declare
>foo() at file-scope, I dunno. As long as it compiles, there isn't
>really a problem in this case.


I suspect he's including a header that already provides a declaration
for foo().


But then what did he mean by "inserted in the calling routine?"


The very thing you have illustrated above, but there is already a
declaration for foo() in scope, coming from some included header.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: dover | last post by:
/*Copy the line a token at a time into the output*/ copy(istream_iterator<string>(iss), istream_iterator<string>(), ostream_iterator<string>(oss, " ")); What's the meaning of this statement?...
6
by: feminine.aura | last post by:
I have to read a file containing integers into a vector. I could do something like this: ifstream data("file.dat"); istream_iterator<intbegin(data); istream_iterator<intend;...
4
by: nospam_timur | last post by:
Let's say I have two files, myfile.h and myfile.c: myfile.h: int myfunction(int x); myfile.c: #include "myfile.h"
1
by: INeedADip | last post by:
What is the difference between: function setupGrid( param ){......} and setupGrid = function( param ){......} Are there any advantages to doing one over the other?
1
by: wtu | last post by:
function Declaration&Definition -------------------------------------------------------------------------------- " Geroty (const vector<Point3D>& poly, const Plane& Tr)" As i'm c++ beginner...
1
by: Lawrence Spector | last post by:
Base base; BaseWrap& baseWrap(reinterpret_cast<BaseWrap&>(base)); boost::python::object obj(boost::shared_ptr<BaseWrap>(&baseWrap)); // Compile error Results in this error: ...
4
by: florian.loitsch | last post by:
I wondered what should be the result of the following code: === function f() { x = false; function x() {}; alert(x); } === According to Ecmascript-spec we have the following rules: 10.1.3:...
29
by: Ravishankar S | last post by:
Dear C Experts, While prepating a content for a C course,I made section on function prototypes. Could you kindly provide me your comments on its correctness. Thank you ! Q12: What is the...
13
by: Sri Harsha Dandibhotla | last post by:
Hello all. I recently came across a function declaration as : char(*(*x()))(); This was not in some code but it was in a C questions thread on some group. I tried to decipher what it returns but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.