[comp.sys.mac.programmer] MPW C 3.0 question

ccc_ldo@waikato.ac.nz (02/16/90)

Can anybody tell me why the following program throws up an error with
MPW C 3.0?

    typedef unsigned char
	Str255[256];

    main()
      {
	Str255
	    temps, *tempp;

	tempp = &temps;
      }

Here's the error report:

#
#	tempp = &temps;
#	              ?
### Error 225 Incompatible types for assignment
#--------------------------------------------------------------------------------------------------------------------------------
    File "test.c"; Line 9
#--------------------------------------------------------------------------------------------------------------------------------

I don't think it's anything to do with the ANSI C standard, as it does
compile with VAX C.

Lawrence D'Oliveiro
Resident Mac fanatic and sworn enemy of diskless workstations
Computer Services Department, University of Waikato, Hamilton, New Zealand
"### Error 57 a typedef name was a complete surprise to me at this point
    in your program"

russotto@eng.umd.edu (Matthew T. Russotto) (02/16/90)

In article <152.25dc364d@waikato.ac.nz> ccc_ldo@waikato.ac.nz writes:
>Can anybody tell me why the following program throws up an error with
>MPW C 3.0?
>
>    typedef unsigned char
>	Str255[256];
>
>    main()
>      {
>	Str255
>	    temps, *tempp;
>
>	tempp = &temps;
>      }
>
>Here's the error report:
>
>#
>#	tempp = &temps;
>#	              ?
>### Error 225 Incompatible types for assignment
>#--------------------------------------------------------------------------------------------------------------------------------
>    File "test.c"; Line 9
>#--------------------------------------------------------------------------------------------------------------------------------
tempp is a pointer variable.  temps is a pointer CONSTANT.  By asking for
a pointer to a pointer constant, you are making a nonsense request (though
most C's will ignore it and the '&', and MegaMax REQUIRED the '&')
Try tempp=temps;
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?

zben@umd5.umd.edu (Ben Cranston) (02/17/90)

In article <152.25dc364d@waikato.ac.nz> ccc_ldo@waikato.ac.nz writes:

> Can anybody tell me why the following program throws up an error with
> MPW C 3.0?
>    typedef unsigned char
>	Str255[256];
>    main()
>      {
>	Str255
>	    temps, *tempp;
>
>	tempp = &temps;
>      }

because temps is a reference to an array without an explicit index, it
resolves to the address of the array itself.  Thus either of these two
would be just fine:

       tempp = temps;
       tempp = &temps[0];

This is the way C works...

-- 
Sig     DS.L    ('ZBen')       ; Ben Cranston <zben@Trantor.UMD.EDU>
* Network Infrastructures Group, Computer Science Center
* University of Maryland at College Park
* of Ulm