[comp.std.c] type compatibility

diamond@jit533.swstokyo.dec.com (Norman Diamond) (05/29/91)

In article <1991May15.205506.24139@athena.mit.edu> tada@athena.mit.edu (Michael J Zehr) writes:
>suppose you have file1.c:
>  typedef Name char[10];
>and file2.c:
>  typedef Name char[10];
>is this technically correct (i.e. ansi conforming)?  it works correctly
>on my compiler, however my version of lint (lintplus from IPT for VMS)
>complains that something is supposed to take an array argument and it's
>getting a pointer argument.

You should get error messages for that typedef syntax.
However, C has no such thing as an array argument, and your version
of lint doesn't seem to be for the C language.

If you have file1.c:

   typedef char Name[10];
>  void something(Name x);
>  void foo(void) {
>    Name x;
>    something(x);
>  }

and file2.c:

   typedef char Name[10];
>  void something(Name x) {
>  }

then it is impeccable ANSI C.  something is supposed to take a pointer
argument, and gets one.
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.

tada@athena.mit.edu (Michael J Zehr) (05/30/91)

In article <1991May15.205506.24139@athena.mit.edu> tada@athena.mit.edu (I) wrote:
>suppose you have file1.c:
>  typedef Name char[10];

yes, this *was* supposed to be typedef char Name[10];
no, i didn't really have that in my file.

(i hate not having a network connection from my development machine --
it means i can't simply cut-and-paste or include the actual code,
generating lots of careless typos when i post an example like that.)

thanks to everyone for the responses.

-michael j zehr