home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sun4nl!and!jos
- From: jos@and.nl (Jos Horsmeier)
- Newsgroups: comp.lang.c
- Subject: Re: I disagree with lint(1)
- Keywords: lint, classic C
- Message-ID: <3381@dozo.and.nl>
- Date: 7 Sep 92 10:05:33 GMT
- References: <1992Sep7.083401.2587@sci.kun.nl>
- Organization: AND Software BV Rotterdam
- Lines: 60
-
- In article <1992Sep7.083401.2587@sci.kun.nl> hansm@cs.kun.nl (Hans Mulder) writes:
- |typedef struct foo *bar;
- |
- |fun(b)
- |bar b;
- |{
- | b=b;
- |}
- |
- |struct foo
- |{
- | int i;
- |} the_struct;
- |
- |main()
- |{
- | fun(&the_struct);
- | return 0;
- |}
- |
- >Lint(1) says:
- |
- |fun, arg. 1 used inconsistently foo.c(5) :: foo.c(16)
- |I disagree. The first argument to fun is a pointer to struct foo on both
- |lines. In my book, that's the same.
- |What do you all think?
-
- I think lint is right. The C compiler only does a `shallow type comparison',
- i.e.
-
- struct foo {
- int i;
- };
-
- struct bar {
- int i;
- };
-
- are two completely different structure types even though their contents
- are identical (to us.) The compiler stores the names of the identifiers
- in a couple of name spaces:
-
- - label names
- - structure tag names
- - for every structure, a separate structure member name space
- - all other identifiers (inlcuding typedef'd names)
-
- Very, very, very old C compilers didn't have a separate name space for
- the structure members, but I'm talking about the Pleistocene here ...
-
- Because the C compiler (and lint) just doesn't check the _contents_
- (or description) of the types (it just finds the name `bar' in the
- last name space and the name `foo' in the structure tag name space,)
- it comes to the conclusion that you're using inconsistent pointer types.
-
- Does this clarify things a bit?
-
- kind regards,
-
- Jos aka jos@and.nl
-