Re: printf() function



On Sun, 10 Feb 2008 14:04:38 -0600, Malcolm McLean wrote
(in article <vJOdnfYxWs9IxTLanZ2dnUVZ8uWdnZ2d@xxxxxx>):

"Bart" <bc@xxxxxxxxxx> wrote in message

But if the compiler allows void main(), knowing it could cause a
problem, and the user hasn't said 'ignore it, I know what I'm doing',
then that compiler is in error I think.

The compiler writer is being absurd.

Really? Does the "knowing it could cause a problem" not give you any
pause at all? Or you think it is absurd to warn about something that
the compiler writer /knows/ could be an issue? That's a rather strange
response.

What if the runtime on that platform will crash due to stack corruption
if the return value isn't provided correctly? You're making an
assumption that it will magically handle that. A lot of systems do
have provisions that allow you to get away with it. That said, they
wouldn't have to if it were not so common to write main incorrectly.

What about this one:

struct mystruct main(void) { ... }

Should that also work quietly? hint: It'll often blow up in
spectacular fashion with variable degrees of excitement based upon
struct's layout. Why wouldn't it work? void main() works on some
systems, but isn't in the standard, so why not any other?

However if the code fails to compile
when a -pedantic / -strict or similar option is set, then it is both within
its rights and sensible.

This argument goes to whether or not a C compiler should be a strict
compiler by default, or only after setting a bunch of special flags. I
tend to think that if compilers were more strict by default, fewer
programmers would use "bad habits" only to discover later that they
have built a large code base with various issues, portability being the
most common variety.

Why help out the experts who need special features by default, and
potentially limit the learning curve for everyone else? Anyone that
knows enough about the language to know what exceptions they want to
the standard language by default should also know enough to configure
the development tools and/or project build system to handle their
needs. This is quite often not the case for those just learning the
language.

--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw





.



Relevant Pages

  • Re: access(FULLPATH, xxx);
    ... with "trial& error" to just silence the compiler. ... void *foo); ... given that the language in the specification _was_ abiguous and both ... documentation was paramount. ...
    (freebsd-questions)
  • Re: access(FULLPATH, xxx);
    ... with "trial& error" to just silence the compiler. ... void *foo); ... given that the language in the specification _was_ abiguous and both ... documentation was paramount. ...
    (freebsd-questions)
  • Re: some strange for me (addition)
    ... struct object_t{ ... The line above cannot be accepted by a C compiler. ... void free; ... If you are using some language other than C, ...
    (comp.lang.c)
  • Re: port I/O abstraction macros
    ... Radio Compiler division. ... real world than knowing how to parse an arithmetic expression. ... they need is to build some sort of primitive lexer. ...
    (comp.arch.embedded)
  • Re: port I/O abstraction macros
    ... without knowing how to write a compiler, ... get a B.S.C.S without knowing how to design an FM radio. ... an FM radio unless you are directly going into Sony's Radio Compiler ...
    (comp.arch.embedded)