thoth@banana.cis.ufl.edu (Robert Forsman) (01/11/89)
I started my C career on PCs and got quite used to strong typechecking on Turbo C. I switched to Unix and all my C programs were useless until I found gcc (the cc we have doesn't support stuff like char *strdup(char *s); function prototyping.) gcc is fine but I still get sloppy and do stuff like fprintf("%s : line %d : colon expected.\n",filename,linenumber); I forget the stream and the program crashes. Turbo catches this and gcc doesn't. If anyone knows of a compiler with STRONG ( I mean really vicious) typechecking, but, in the spirit of C, no enforcing, I would really like to know where I can ftp it from. I guess what I am looking for is a compiler with lint built in. I have access to Suns and an ancient Gould but little else. p.s. our lint chokes on my function prototyping THOTH out -
gwyn@smoke.BRL.MIL (Doug Gwyn ) (01/11/89)
In article <19620@uflorida.cis.ufl.EDU> thoth@banana.cis.ufl.edu () writes: >fprintf("%s : line %d : colon expected.\n",filename,linenumber); >Turbo catches this and gcc doesn't. I'm somewhat surprised that GCC doesn't catch this, since the correct prototype in <stdio.h> would be int fprintf(FILE *, const char *, ...); and the compiler should be able to validate the first two argument types.
tkacik@rphroy.UUCP (Tom Tkacik) (01/12/89)
In article <9335@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: >In article <19620@uflorida.cis.ufl.EDU> thoth@banana.cis.ufl.edu () writes: >>fprintf("%s : line %d : colon expected.\n",filename,linenumber); >>Turbo catches this and gcc doesn't. >I'm somewhat surprised that GCC doesn't catch this, since the >correct prototype in <stdio.h> would be > int fprintf(FILE *, const char *, ...); >and the compiler should be able to validate the first two argument types. Unfortunately, GCC does not come with its own stdio.h file. The standard one is typically used, and does not have function prototypes. All GCC sees for fprintf is int fprintf(); if that. Usually, as on our Suns, fprintf is not even listed in stdio.h. --- Tom Tkacik GM Research Labs, Warren MI 48090 uunet!umix!rphroy!megatron!tkacik
bobmon@iuvax.cs.indiana.edu (RAMontante) (01/12/89)
I also grew up (am still growing, actually) in Turbo C, and about to assist a course that will use beginning C under Unix. Does anyone know of a lint that understands dpANS constructs? This would make life a lot easier for the students, I like to believe.
schmidt@siam.ics.uci.edu (Doug Schmidt) (01/12/89)
In article <9335@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: |>In article <19620@uflorida.cis.ufl.EDU> thoth@banana.cis.ufl.edu () writes: |>>fprintf("%s : line %d : colon expected.\n",filename,linenumber); |>>Turbo catches this and gcc doesn't. |> |>I'm somewhat surprised that GCC doesn't catch this, since the |>correct prototype in <stdio.h> would be |> int fprintf(FILE *, const char *, ...); |>and the compiler should be able to validate the first two argument types. Unfortunately, most people don't change their standard #include files when they install gcc. On my sun, for example, fprintf isn't even mentioned in /usr/include/stdio.h. Therefore, gcc will only catch this if a conscientious gcc installer has modified the standard include files or changed cccp (the gnu cpp) to look in another directory first. Doug Schmidt -- schmidt@ics.uci.edu (ARPA) | Per me si va nella citta' dolente. office: (714) 856-4043 | Per me si va nell'eterno dolore. | Per me si va tra la perduta gente. | Lasciate ogni speranza o voi ch'entrate.
meissner@xyzzy.UUCP (Michael Meissner) (01/13/89)
(Gnu.gcc people -- this appeared in comp.lang.c on USENET) In article <9335@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: | In article <19620@uflorida.cis.ufl.EDU> thoth@banana.cis.ufl.edu () writes: | >fprintf("%s : line %d : colon expected.\n",filename,linenumber); | >Turbo catches this and gcc doesn't. | | I'm somewhat surprised that GCC doesn't catch this, since the | correct prototype in <stdio.h> would be | int fprintf(FILE *, const char *, ...); | and the compiler should be able to validate the first two argument types. Actually, GCC will report the type mismatch providing whomever installs it adds prototypes to the standard header files. The original author consider taking the time to do it (and hopefully add smarts to `fixincludes' to do this automagically for future revisions). After all, GNU is a cooperative effort. -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner Arpa: meissner@dg-rtp.DG.COM (or) meissner%dg-rtp.DG.COM@relay.cs.net -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner Arpa: meissner@dg-rtp.DG.COM (or) meissner%dg-rtp.DG.COM@relay.cs.net
raw@ushiva.UUCP (Roland Wilcher) (01/15/89)
In article <16398@iuvax.cs.indiana.edu> bobmon@iuvax.cs.indiana.edu (RAMontante) writes: >I also grew up (am still growing, actually) in Turbo C, and about to >assist a course that will use beginning C under Unix. Does anyone >know of a lint that understands dpANS constructs? This would make >life a lot easier for the students, I like to believe. Gimpel software's lint recognizes dpANS contruct under M.S. Dos and is a very good implementation for around $120. It comes with lint libraries for MSC Datalight C Aztec C and Turbo C. --- Every absurdity has a champion to defend it. raw@neologic%hal.crwu.edu {hal,decvax}!ncoast!ushiva!raw Roland A. Wilcher ------------------------------------------------------------------------------
bobmon@iuvax.cs.indiana.edu (RAMontante) (01/16/89)
raw@ushiva.UUCP (Roland Wilcher) writes:
- I write:
-> [ ... ] Does anyone
->know of a lint that understands dpANS constructs? This would make
-
-Gimpel software's lint recognizes dpANS contruct under M.S. Dos and
Sorry, I didn't make myself clear. I need a lint for Ultrix, running on
a VAX 8650. Has to be source, as the sysadmin is understandably leery
of viruses and things. Any pointers would be gratefully appreciated,
the sooner the better (school started last week).
Bob Montante bobmon@iuvax.cs.indiana.edu
Comp. Sci. Dept.
Indiana University
bet@dukeac.UUCP (Bennett Todd) (01/18/89)
To get gcc to typecheck parameters to functions you need to have function prototypes. I have an include file (I posted it here earlier) which contains ANSI-style function prototypes for all the routines in sections 2 and 3 of the UNIX Programmer's Manual. I've since enhanced it to include proper "const" qualifiers (as best I can, I might have still missed some) so that I now can compile with gcc's "-Wall -Wwrite-strings" options, which gives pretty aggressive checking. If anybody is interested in this file let me know. As it stands it #include's everything under the sun; I like this. It doesn't seem to incur any run-time overhead in space or time (by which I mean to say that the unneeded declarations and includes don't seem to change the generated code) and I don't have to #include any of the system files. If you didn't like this behavior the file could be split into separate sets of function prototypes which could be imbedded (within #ifdef __STDC__ / #endif) in the appropriate /usr/include files. Specifically, to get gcc to give the desired warning on the common error fprintf("format", args); (omitting the needed stream parameter) you would want the following prototype in scope: int fprintf(FILE *, const char *, ...); -Bennett bet@orion.mc.duke.edu