At Nazi Camp!
You've obviously never written a compiler, nor taken a class in
compiler theory. The usual practice is to identify each function not
only by its name but also by its return type and the enumerated types
of its parameters. In an object oriented language with polymorphism
this completely avoids the need for syntax that declares that a
function "overloads" a function of identical name but different
configuration.
spinoza1111 <
[email protected]> proves once again that he knows
nothing about C.
In the case of a C program with void main(), the handling is identical
to int main(). The first call is represented by the tuple (main, void)
with a null parameter list. The second is represented by the tuple
(main, int). The standard syntax int main(int argc, char **argv) is
represented by (main, int, int, char**).
spinoza1111 <
[email protected]> proves that he knows nothing about
the interface between something and an C program.
There is no direct interface between the interface int main(...) and a
script or another program. The interface known as main() is well
hidden from the OS, a shell script or other programs in an hosted
environment.
There is an interface between the OS (to be in detail: the program
laungher of the OS and the program that asks for another program to
get launched. This interface does
- fiddle out where the program to launch is located
- do some implementation depend work to transfer the executable from
its external location (hard disk, floppy, CD, somewhere on network
somewhere in the world....) into memory, setup control to it.
After the program ends it will copy the result (as described by the
runtime interace (here the implementation defined by the abstract
mashine defined by the C standard and the OS and the interface of the
implementation of the abstract mashine for int main().
This ends up in undefined behavior from return of main() to the caller
of the program.
So anybody who is trying void main() proves that he knows nothing
about programming at all.
Since implicit overloading isn't allowed in C, two main() procedures
with the same name can be flagged as an error whether or not their
parameters or return types are identical.
If the executable is linked with another program, the complete tuple
is available. If the executable is called by a shell processor, the
shell processor will have to be written by competent people who will
understand that any executable is ONLY guaranteed to start at the
location defined for the single main() procedure. If this main is
void, it will still in most calling conventions return to the address
supplied it on the "stack" with which people with a clue know about.
spinoza1111 <
[email protected]> proves again haing no knowledge
how interprocess communiaction is working.
The only danger point is when your idiot shell procedure BLINDLY tests
the return code from a procedure declared as void main(). But
competent programmers never assume that an executable will return
anything. They consult the "man" page or the source code!
spinoza1111 <
[email protected]> proves again having no knowledge
about reality.
Your ignorance of runtime in fact appeared in CTCN-3 when you
foolishly criticized Schildt for talking about stacks. Your uninformed
speculations about what "might" happen are characteristic of your
desire to replace knowledge by ignorance.
Schidt has proven more than once that he knows nothing about C and
that he is even unable to understund the C standard as hje has
published it himself beside his false annotations lying to any reader
of his books.
To the ignorant, the world is full of fabulous monsters and unknown
terrors. However, main will always have an address and most
architectures will simply branch to this address when the executable
is called, with (in the standard case) the stack preloaded with the
return address, the argument count, and a pointer to a pointer to a
char. If main is declared without parameters the second and third
items will be ignored. If it is declared with different parameters an
error will result. But if the operating system expects in all cases to
find the stack with a usable single value past pre-existing contents,
this is an OS with a bug. This is because the OS can know the
difference, or lack thereof, in stack size before and after it calls
an executable, and when the size does not change, set the return code
to a suitable value.
The only dumbass, ignoring facts is spinoza1111
If the shell procedure makes an explicit request for the return code,
usually using a keyword such as rc, the programmer risks a crash or
worse (continued execution based on garbage results). But all this
means is that competent writers of shell procedures shall diligently
inform themselves as to the main signature of any routine they call.
Certainly, latter-day competent C authors writing main() procedures
should use int main(), but this is a norm, it doesn't describe what's
out there.
Yeah, an dumbass like Schild or his dumb puppet spinoza1111
<
[email protected]> has made the mistake to ignoer the
requirements of each standard and even K&R1 because this is the proven
interface between 2 programs in any existent hosted environment since
more than 40 years. That includes DOS 1.0, TOS, Amiga OS, each unix,
linux, MAC OS, and any other OS spinoza1111 <
[email protected]>
not even knows that it exists.
All that describes int main(...) and equivalent interfaces for any
other programming language. Ony ignorants of real world like
spinoza1111 <
[email protected]> unable to understund facts proven
by anybody else.
--
Tschau/Bye
Herbert
Visit
http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!