C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

implicit declaration

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Jim
Guest





PostPosted: Fri Dec 12, 2003 9:52 am    Post subject: implicit declaration Reply with quote



im very new to c++ and am trying to compile a school project... my
only error is an implicit declartion error. my question is, what
exactly is an implicit declaration? i can't fix it cuz i dunno what
it is. whats worse is it's in code my professor gave to us... i
didn't write it. so debugging her code is twice as hard.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Francis Glassborow
Guest





PostPosted: Fri Dec 12, 2003 7:01 pm    Post subject: Re: implicit declaration Reply with quote



In article <cd155d8b.0312112138.59163c6d (AT) posting (DOT) google.com>, Jim
<gsmcret3 (AT) Juno (DOT) com> writes
Quote:
im very new to c++ and am trying to compile a school project... my
only error is an implicit declartion error. my question is, what
exactly is an implicit declaration? i can't fix it cuz i dunno what
it is. whats worse is it's in code my professor gave to us... i
didn't write it. so debugging her code is twice as hard.

Did she ask you to debug it or did she give it to you as working code?

The closest thing that C++ has to implicit declarations are for compiler
generated default ctor, copy ctor, copy assignment and dtor for a class.

However I am suspicious that what you actually have been given is pre
C99 C source code because C used to allow the compiler to deduce a
function declaration from a use (I think we removed that from the
current version of C). Such deductions were very error prone because
they most often occur as a consequence of forgetting to #include a
header file.

C++ has never allowed deduced function declarations and has always
required a function declaration in the form that C calls a function
prototype.

The above probably does not make much sense at the moment. However try
compiling her code as C rather than as C++. If that works make a mental
note that your instructor sometimes provides poor quality code (maybe
just to test whether you identify it as such) In addition she may not be
entirely clear as to the difference between C and C++.


--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
or http://www.robinton.demon.co.uk


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Carlos Moreno
Guest





PostPosted: Sat Dec 13, 2003 1:55 am    Post subject: Re: implicit declaration Reply with quote



Jim wrote:
Quote:
im very new to c++ and am trying to compile a school project... my
only error is an implicit declartion error. my question is, what
exactly is an implicit declaration? i can't fix it cuz i dunno what
it is. whats worse is it's in code my professor gave to us... i
didn't write it. so debugging her code is twice as hard.

Without seeing the actual compiler error and the code and/or
some more information, we can't be 100% certain.

But this sounds to me like the code is calling a function
without providing a prototype. This is legal in C (though
good compilers typically issue a warning), but not in C++.

Every function you call must have been declared prior to
the first use.

HTH,

Carlos
--

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Ben Hutchings
Guest





PostPosted: Sat Dec 13, 2003 2:02 am    Post subject: Re: implicit declaration Reply with quote

Jim wrote:
Quote:
im very new to c++ and am trying to compile a school project... my
only error is an implicit declartion error. my question is, what
exactly is an implicit declaration? i can't fix it cuz i dunno what
it is. whats worse is it's in code my professor gave to us... i
didn't write it. so debugging her code is twice as hard.

Without seeing the code that produces the error, and the exact error
message, I can only guess at what the error might be.

However, I think the problem is that the code is calling a function
for which no declaration has been given. Perhaps you forgot a
necessary #include directive?

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
John Potter
Guest





PostPosted: Sat Dec 13, 2003 2:21 am    Post subject: Re: implicit declaration Reply with quote

On 12 Dec 2003 14:01:04 -0500, Francis Glassborow
<francis (AT) robinton (DOT) demon.co.uk> wrote:

Quote:
However I am suspicious that what you actually have been given is pre
C99 C source code because C used to allow the compiler to deduce a
function declaration from a use (I think we removed that from the
current version of C). Such deductions were very error prone because
they most often occur as a consequence of forgetting to #include a
header file.

C++ has never allowed deduced function declarations and has always
required a function declaration in the form that C calls a function
prototype.

Good guess. That is a gcc-2.95 error message.

int main () {
f();
}
g++ junk.cpp
junk.cpp:2: implicit declaration of function `int f(...)'

John

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.