Re: What will happen if main called in side main function?



On 31 Mar 2006 09:03:16 -0800, "Ravi" <ravi.wireless@xxxxxxxxx> wrote
in comp.lang.c:

void main()
{
main();
}

int main()
{
main();
}

It seems apparent from a later message you posted in the thread, you
are asking if the above is a valid program. No, it is not, you cannot
have two functions with external linkage and the same name in a
program. And you cannot have two functions with the same name in a
single translation unit, regardless of linkage.

And main() must be defined with a return type of int.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
.



Relevant Pages

  • Re: Help wanted on some source codes
    ... void main ... are two variables called 'x' with external linkage. ... mean that function fis actually refering to the double x instead of the int x? ... But suppose one of these was an "extern" declaration instead, ...
    (comp.lang.c)
  • Re: Read-only outside translation unit
    ... I want this object to be accessible from other translation units, ... it external linkage. ... extern int const i; ... (from outside its home module) ...
    (comp.lang.c)
  • Re: Templates
    ... > expression where a pointer to int is expected, ... IIUC all that matters here is that Y has external linkage. ... char with external linkage. ...
    (comp.lang.cpp)
  • Re: Read-only outside translation unit
    ... I want this object to be accessible from other translation units, so I give it external linkage. ... extern int const i; ... because the const and non-const declarations ...
    (comp.lang.c)
  • Re: How Globals is handle in C.
    ... int x = 1; ... foo.h provides the declaration of x as 'int x' but does not provide an address. ... Because x has external linkage, foo.o will provide the linker with its address. ...
    (comp.lang.c)