jim@ektools.UUCP (James Hugh Moore) (09/21/87)
I am a system manager, and some people on a development project on our VAX 11/750 running Ultrix 1.2 have asked about adding constructs to be recognized by lint. Specifically, they are doing development on our VAX and using Tektronix software to generate 68000 code. The Tektronix software supports const and volatile declarations for data. Well lint complains bitterly about these. With our management being very pleased that our folks are using lint, they have asked me to investigate anything I could do to shutup lint in these cases. I have looked in the supplemental documentation, and couldn't figure out how to get lint to pass over these constructs. I suppose I could write a filter for lint's output, but I was wondering if anyone had a better way. Thanks, I appreciate your time. I think that this might be of interest to the net, but email to me if you think it is appropriate. May God Bless You, in Jesus Name Jim Moore - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - James H. Moore, Software Tools Group Product Software Engineering Lab Eastman Kodak Co. Email: allegra!rochester!kodak!ektools!jim USMail: Dept 47, EP 5-2, Eastman Kodak Co., Rochester, NY 14650 Disclaimer: Opinions expressed are my own, and DO NOT represent the opinions or policies etc of Eastman Kodak Co. as a whole. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rsalz@bbn.com (Richard Salz) (09/22/87)
In comp.unix.questions (<832@ektools.UUCP>), jim@ektools.UUCP (James Hugh Moore) writes: >... The Tektronix >software supports const and volatile declarations for data. Well lint >complains bitterly about these... The easiest thing to do is to take advantage of the fact that "lint" essentially puts a "#define lint" at the start of all your files. So find some system-wide header file (e.g., /usr/cross-compiler/stdio.h?), and add these lines to it: #ifdef lint #define const /* Until we get an ANSI-lint... */ #define volatile /* Until we get an ANSI-lint... */ #endif /* lint */ Put similar wrappers around your function prototypes. -- For comp.sources.unix stuff, mail to sources@uunet.uu.net.
gwyn@brl-smoke.ARPA (Doug Gwyn ) (09/22/87)
In article <832@ektools.UUCP> jim@ektools.UUCP (James Hugh Moore) writes: >The Tektronix software supports const and volatile declarations for data. >Well lint complains bitterly about these. lint -Dconst= -Dvolatile= sources.c
ado@elsie.UUCP (Arthur David Olson) (09/22/87)
In article <6457@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > In article <832@ektools.UUCP> jim@ektools.UUCP (James Hugh Moore) writes: > >The Tektronix software supports const and volatile declarations for data. > >Well lint complains bitterly about these. > > lint -Dconst= -Dvolatile= sources.c Which will get the code past lint, and will leave you with code that isn't portable to sites with existing C compilers (for example, 4.[123]BSD sites). The better approach is a variant of one suggested by an earlier poster: handle the const/volatile vagaries in a header file. Suggested: #ifndef __STDC__ #define const #define volatile #endif /* __STDC__ */ Note that neither the command-line approach nor the header file approach will help if you have declarations such as const x = 3; in which const (or volatile) is the only keyword in the declaration. But from what I've been reading X3J11 may be moving in the direction of outlawing such declarations; they should be avoided. -- CC is a registered trademark of the Institute for Scientific Information, Inc. Lint is an Oscar Madison trademark. -- ado@vax2.nlm.nih.gov ADO, VAX, and NIH are trademarks of Ampex and DEC.
daveb@geac.UUCP (Brown) (09/23/87)
In article <7479@elsie.UUCP> ado@elsie.UUCP (Arthur David Olson) writes: >Note that neither the command-line approach nor the header file approach >will help if you have declarations such as > > const x = 3; > >in which const (or volatile) is the only keyword in the declaration. But from >what I've been reading X3J11 may be moving in the direction of outlawing such >declarations; they should be avoided. Iff const is a storage-class specifier (K&R Appendix A, 8.1, p192ff), then it is plausable to set "-Dconst=auto", and have the compiler detect when the construct is portable by barfing on "auto static"... This will get you past both lint and less-capable compilers when you go to port the porgram. --dave -- David Collier-Brown. {mnetor|yetti|utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.
whp@apr.UUCP (09/24/87)
It is a bad idea to modify your source code (such as lint). The simpler approach is to add a global include file: #ifdef lint #define volatile ... #endif You can also use command line arguments to lint to accomplish the same thing. If you really need to modify lint, you must modify the yacc grammar which is used for lint. As I recall, the semantics of volatile and const place them in the "sc-specifier" class, just like register or auto. If you were to search the grammer source files for the keyword "auto", I'd bet you could then use it as a guide for "volatile" or "const". Since the grammar for lint is just a recognizer, there are probably no code sequences needed. -Wayne Pollock PS DISCLAIMER: I have never attempted to modify lint! I probably don't know what I'm talking about! If you try this (which I don't recomend) and damage you system, I don't want to hear about it! (In short, add the header file or use the command line options!)
karl@haddock.ISC.COM (Karl Heuer) (09/25/87)
In article <279@apr.UUCP> whp@apr.UUCP (Wayne Pollock) writes: >It is a bad idea to modify your source code (such as lint). The simpler >approach is to add a global include file: > #ifdef lint > #define volatile > ... > #endif If (as is traditional) lint is implemented as a shell script, then modifying the "source code" is trivial: search for "-Dlint"; add "-Dvolatile= -Dconst=". As has been mentioned, this doesn't handle warts like "const x=3;". >If you really need to modify lint, you must modify the yacc grammar which is >used for lint. As I recall, the semantics of volatile and const place them >in the "sc-specifier" class, just like register or auto. You recall incorrectly. At most one storage-class-specifier may be given in a declaration, but "auto const" and "static const" and "extern const" are all legal. As of the Oct86 dpANS const is a type-specifier like "int", but I've heard X3J11 is rewriting this part. Note also that a declaration such as "const char * const x" is legal, and does not mean the same thing as either "const char * x" or "char * const x". Of course, a REAL fix would not just ignore the new keyword; an ANSI lint should warn about a cast from const to non-const, or an apparent attempt to modify a const. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint (I have directed followups to comp.lang.c only)