Article View: gnu.gcc.help
Article #53382type checking with gcc
From: Richard Stallman
Date: Thu, 09 Jan 1992 09:19
Date: Thu, 09 Jan 1992 09:19
25 lines
1926 bytes
1926 bytes
Are the type-checking capabilities of gcc with ANSI any substitute for
lint? I noticed that many parameter differences we're ignored using
gcc, and caught with lint.
The ANSI C typechecking capabilities are a substitute for lint, but only
if you use them. If you declare a function prototype, then all calls
convert the arguments to the expected type, or report errors when
arguments cannot be converted.
However, passing a character where a float is expected is not an error,
because the conversion is possible.
In ANSI C, enum types are abbreviations for standard integral types,
and enum values are actually integers. So you won't get an error if
the function "asks for" an enum type and the actual argument is an
integer. This case normally does not even require conversion.
In order to make your program compilable using traditional C, I suggest
keeping the function definitions in traditional form, and adding a
separate prototype declaration inside of #ifdef __STDC__.
Keep in mind when doing this that if the traditional function definition
declares an argument of type char or short, the prototype must say int;
if the function definition declares an argument of type float, the
prototype must say double. This is also part of the ANSI standard.
Technical Details
Message-ID:
<9201091919.AA10242@mole.gnu.ai.mit.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!gnu.ai.mit.edu!rmsReferences:
<1992Jan9.154511.9240@vicorp.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,a7ee8f525dc565b0 X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-01-09 11:39:28 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!gnu.ai.mit.edu!rms From: rms@gnu.ai.mit.edu (Richard Stallman) Subject: type checking with gcc Message-ID: <9201091919.AA10242@mole.gnu.ai.mit.edu> Sender: daemon@cis.ohio-state.edu Organization: GNUs Not Usenet References: <1992Jan9.154511.9240@vicorp.com> Distribution: gnu Date: Thu, 9 Jan 1992 09:19:43 GMT Lines: 25