Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!hp4nl!philapd!ssp1!roelof From: roelof@idca.tds.PHILIPS.nl (R. Vuurboom) Newsgroups: comp.lang.c Subject: Re: C Style help requested Message-ID: <264@ssp1.idca.tds.philips.nl> Date: 28 Sep 89 18:21:11 GMT References:Organization: Philips Telecommunication and Data Systems, The Netherlands Lines: 91 In article dg3s+@andrew.cmu.edu (David Gentzel) writes: >A friend of mine has been put in charge of coming up with a C (and C++) style >guide for his company. The goals are > > 1) Name and comment conventions to enhance comprehension and > maintainability on projects with large numbers of programmers. > 2) Guidelines for writing portable code. > 3) Common coding mistakes to avoid (and the usual symptoms if they > are not avoided). Maybe there's no need to re-invent the wheel on this one. For portabilty issues the best book (by far) I've seen on this subject is: Portability and the C language Rex Jaeschke Hayden Books (1988) ISBN-0-672-48428-5 Jaeschke also discusses the impact of the ANSI-C standard which is particularly interesting for this group and the group next door (comp.std.c). Another interesting book on portability is: Portable C and UNIX System Programming J.E. Lapin Rabbit Software Prentice-Hall (1987) ISBN-0-13-686494-5 This book is aimed specifically at porting code between UNIX and its derivative systems. It describes a port philosophy, briefly covers C language issues, and concentrates on the operating system and library issues. The best I've seen on coding style standards is something Philips has come up with: C Coding Standards (Release 1.1). J.Aerts and J.Langhout (1988) Order nr: 12NC: 4322 270 50001 Its about 70 pages thick. An (arbitrary) sample section: 6.2 The use of ++ and -- These operators are very often used in the manipulation of pointers. Together with the definition of "register pointer" these operators may result in a saving of both execution time and program space. The use of "name_p++;" is preferred to "name_p = name_p + 1;" as the former is more suited for the task of setting a pointer to the next element in of an array. Do not use "++" and "--" in actual function or macro parameters, e.g: call_fn(x++,y++,*x,*y); /* WRONG */ Avoid the use of "++" and "--" in combination with other operators. Such may easily lead to mistakes in the expected evaluation order and the side effects that go with it. Its not for the C expert (what standard is? :-). But its pretty good for the beginner/intermediate C programmer. I don't know the price now but last I heard they were selling for all of 5 bucks. Of course if it has to go overseas and they know you rich americans are interested ...:-). See telephone nr and address below if you're still interested. CST Sales,Service and Support Centre for Software Technology Nederlandse Philips Bedrijven B.V. Building HOE 1.15 P.O. Box 80000 5600 JA Eindhoven The Netherlands tel nr. +31 40 743561 +31 40 744696 -- wiskunde: Dutch for mathematics. Literally: Knowledge of certainty wis: certainty kunde: Knowledge Roelof Vuurboom SSP/V3 Philips TDS Apeldoorn, The Netherlands +31 55 432226 domain: roelof@idca.tds.philips.nl uucp: ...!mcvax!philapd!roelof