Re: Ahead of "main"?



mdh wrote:
On Apr 29, 1:41 pm, Eric Sosman <esos...@xxxxxxxxxxxxxxxxxxx> wrote:
[...]
Here's a point to ponder: A function definition --..... also declares it (two
two-syllable verbs both beginning with DE, but they are not
the same). It is possible to declare a function without
defining it,......
[...]
So, if I understand you correctly, in my case for a small program, the
key seems to be to understand that a declaration needs to occur prior
to the function being called.
Where that declaration actually occurs (prior to main, or within main)
( under these limited circumstances) is of no consequence. However,
once one gets into the "real" world of C, this would be good
programming ( as you noted with seperate .h files), so I may as well
get used to practising good style!!

I think you are still confusing "declaration" and
"definition." You should declare every function before
trying to call it (modern compilers change "should" to
"must"), but you can define the function wherever you
like. Since a definition is also a declaration (but not
vice-versa), if you define the function before calling
it you don't need a separate declaration. If you define
the function after calling it, or if you define it in a
separately-compiled file, you need a declaration prior
to the first call.

Eventually this will make sense. Trust me.

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx
.



Relevant Pages

  • The conduct of the wife of the pastor- mother of these twins, after I sent this document of 01,
    ... The conduct of the wife of the pastor- mother of these twins, ... as though she conducts herself with the threat of court against me, ... positions employment related prior to me arriving at her congregation ... in this declaration I have mr. Gideon who conducts ...
    (soc.religion.quaker)
  • Re: main prototype pointless?
    ... this is a non-prototype declaration that is permitted only ... I have vague memories that prior declarations mainare prohibited, ... providing a seperate prototype declaration for mainprior to the one ... If your program calls mainfrom other translation units, ...
    (comp.lang.c)
  • Re: Template-member definition
    ... > Why doesn't the following code compile? ... > MSVC7 gives this error: ... > existing declaration ... Prior to version 7.1, VC++ didn't allow member templates to be defined ...
    (comp.lang.cpp)
  • Re: compile error
    ... It means that whatever is highlighted (e.g., an external function ... declaration) cannot be declared within a Sub or Function ... Move that item outside of and prior to any procedure. ...
    (microsoft.public.excel.programming)
  • IntPtr.Zero to PVOID - Invalid pointer
    ... I've tried various ways of changing the declaration and what I pass ... muck with the declarations for the GUID parameters since the compiler ... believes the MIDL structure GUID is different from the C# type Guid.) ... remove declarations for interfaces which I'm not even calling. ...
    (microsoft.public.dotnet.csharp.general)