473,569 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 15062
"Phil Reardon" <pc**@pcrt.co m> 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_n o_consequence(v oid)
{
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********@com cast.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.n et> wrote:
"osmium" <r1********@com cast.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*******@free net.de)
Nov 13 '05 #7
In <m3************ @localhost.loca ldomain> Micah Cowan <mi***@cowan.na me> writes:
"Phil Reardon" <pc**@pcrt.co m> 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_n o_consequence(v oid)
{
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
implementati on "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********@com cast.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.loca ldomain> Micah Cowan <mi***@cowan.na me> writes:
"Phil Reardon" <pc**@pcrt.co m> 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_n o_consequence(v oid)
{
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
implementati on "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

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

Similar topics

14
2089
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? Thanks!
6
1419
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; vector<intc(begin,end); Now this does what i want it to.
4
6098
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
1896
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
1331
by: wtu | last post by:
function Declaration&Definition -------------------------------------------------------------------------------- " Geroty (const vector<Point3D>& poly, const Plane& Tr)" As i'm c++ beginner the following Function Declaration and Definition couldnt understandable? so explain me what kind of Declaration this is."const vector<Point3D>&...
1
2030
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: 1>PythonPassReference.obj : error LNK2019: unresolved external symbol "class boost::python::api::object __cdecl obj(class boost::shared_ptr<struct BaseWrap&)"...
4
1781
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: "For each FunctionDeclaration ... create a property of the
29
8061
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 difference between a function prototype and a function declaration? If you get this right, you must have done fair amount of research on C
13
1959
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 couldn't make complete sense out of it. Can someone please explain what this function is supposed to return and expand it step by step. Thanks,
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.