Re: [Maybe OT] How to convince people about the importance of ANSI standards conformance ?

From: Jack Klein (jackklein_at_spamcop.net)
Date: 01/19/04


Date: Mon, 19 Jan 2004 05:22:34 GMT

On 18 Jan 2004 20:45:44 -0800, root@zworg.com (Amarendra GODBOLE)
wrote in comp.lang.c:

> Hi,
>
> I am working on a legacy user space app, which has been developed
> entirely in C, some 15 years ago. Needless to say, it does not even
> partially conform to any standard.
>
> My team is in the process of adding new features to this app. As a
> start off, I asked them to write clean code, which conforms to certain
> aspects of the ANSI standard. I am no authority on the standard, and
> my knowledge is based on C Unleashed.
>
> For that I asked them to --
> 1. Avoid identifier names starting with _.
> I asked them to change the following structure --
>
> typedef struct _foo {
> ...
> } Foo;
>
> to
>
> typedef struct foo_ {
> ...
> } Foo;

Note that it is almost never necessary, or particularly helpful, to
provide both a structure tag and a typedef for a structure definition.
Don't do this unless you need it.

> 2. Avoid clashes with the system namespace. To avoid id names
> beginning with str, is, etc.
>
> I thought by making them aware of such issues, we can probably write
> code which is more clean, easy to maintain, and partly conforming to
> ANSI.
>
> But they fail to see my point of conformance and I am faced with
> issues like --
> 1. How will we trample the system namespace with names like
> _DBGetFooRecord etc.

Maybe you will, maybe you won't. That's exactly the point, that
namespace is reserved for the language standard (__FILE__, and such)
and for the implementation, meaning the compiler and it's headers.

You can come up with some incredibly hard-to-find bugs when you try to
build your old code with a new compiler, or even a newer version of
your current compiler, and somewhere in the compiler internals or in
some private include file is a macro or intrinsic symbol that matches
one of your identifiers.

> 2. Standards etc are junk and in no way we are to conform to that. We
> are going to write code the way _we_ feel it.

Is this a volunteer open source project or a commercial product? Are
you dealing with professional programmers or trying to teach a class
of crabby pre-schoolers?

One of the reasons for the incredible amount of defective software
today is the cowboy know-it-all attitude of far too many programmers.
Those who still see programming as an art and not as a science or
engineering discipline might be beyond help.

If the worked for me, they would change their attitudes or find
themselves looking for a new job.

> My defense was all that I have learned from C Unleashed, but it is
> proving to ve weak. I'd like you all from clc to help me make my
> defense stronger, so that I can make them see some light !
>
> I am not sure if this mail is OT or OT (On or Off), but nevertheless I
> am posting it.
>
> Cheers,
> Amarendra

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
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: pointer one past malloc.ed memory
    ... Specifically, the compiler transforms: ... When not optimizing, the compiler ... to make this work (in Standard C). ... the system as a whole can still conform. ...
    (comp.lang.c)
  • Re: Storgae durations
    ... standard you referred to is no longer current. ... advocating C99 and saying that C90 is obsolete, ... But if the implementation *doesn't conform*, ... very often the compiler *doesn't* make that decision. ...
    (comp.lang.c)
  • [Maybe OT] How to convince people about the importance of ANSI standards conformance ?
    ... I am working on a legacy user space app, ... partially conform to any standard. ... typedef struct _foo { ... Standards etc are junk and in no way we are to conform to that. ...
    (comp.lang.c)
  • Re: 5th anniversary of 3.4.3, ideas
    ... The accepting compiler doesn't conform to the C++ standard. ... the Nethack source code for is an empirical test case. ...
    (rec.games.roguelike.nethack)
  • Re: compile detection of powf, etc
    ... >> Is there a standard way using the preprocessor to detect if a given C ... >> float powf; ... It means that the compiler *claims* to conform to C99. ...
    (comp.lang.c)