Re: Linux compiling

From: Paul F. Johnson (paul_at_all-the-johnsons.co.uk)
Date: 12/03/04


Date: Fri, 03 Dec 2004 12:46:56 +0000

Hi,

Alwyn wrote:
> On Thu, 02 Dec 2004 21:04:40 -0600, Jack Klein wrote:

>>There are quite a few things that are popular among the careless and
>>ignorant. Do you think we should encourage carelessness and
>>ignorance?
>
> What is it about Usenet that makes people get so worked up over such
> trivialities as the correct return type of a C function and make
> violent personal attacks on those whom they perceive to be in disagreement
> with them? Why do programming languages generate the kind of emotion among
> the geeky that one associates with religion and politics in normal people?

The problem is many fold.

For a start, void main has *never* been correct and as Jack has said, it
really is undefined what happens. Are you seriously suggesting that
someone trying to learn should take the Schildt approach of "it's wrong,
but what they hey, it compiles doens't it!" - we all know how many
problems that causes down the lines.

While a specific version of a compiler may accept void main, that
doesn't make it right either. MS compilers for a long time used to
change int main to void main if a return was omitted instead of issuing
a warning - so from slightly broken to completely broken happened. Not
good by any stretch of the imagination - worse than that, to save time,
college lecturers would actually *teach* void main as being correct so
they didn't need to answer the questions about what the warning or
message was!

main() is also probably the single most function as it's the first one
which is executed and unless there is an abnormal abort, the final one
exectuted to return control. Other applications rely on a return value
from main. If they don't get one due to someone using a void return type
(or for that matter, any other non-int return type), then the process
stops and that's it - you have other programs not working due to that
problem.

As to the personal attack, I think you're over reacting. You've been
around here long enough to realise that if you give such advice that
it's not a biggy if you give main the wrong return type that you will
get jumped on as it's such a fundamental mistake. It is a biggy and to
say it's not really does you, and this group, a disservice.

I hope that explains why Jack said what he did.

TTFN

Paul



Relevant Pages

  • Re: Calling a managed function from native code
    ... running on top of the CLR but which is isn't garbage collected. ... compiles to IL which is JIT compiled and runs on top of the CLR. ... void test() { ... You can't do that, String is not disposable, it doesn't have a destructor, it doesn't have a Dispose method. ...
    (microsoft.public.dotnet.languages.vc)
  • (no subject)
    ... your module compiles fine on my box using this method ... > I have tried to compile the hello.c module under kernel 2.6.3. ... > int initial_module (void) ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: why does it crash?
    ... Could you be more specific at which line it crashes, ... vectorCities; ... > this program compiles, but crashes when run. ... > void output(); ...
    (comp.lang.cpp)
  • Re: CW10 assignment, void*, func ptr warnings...
    ... In any case, your code compiles just fine in my application, so I don't ... know why you're getting a warning. ... > when going from the void* back to a func ptr cast. ...
    (comp.sys.mac.programmer.codewarrior)
  • Re: vulnerabilities
    ... Even if it compiles, ... >void memset ... I guess C++ allows using the memset ... Dan Pop ...
    (comp.lang.c)