Re: [cc65] malloc and Sort.c(26): Error: Expression expected

Date view Thread view Subject view

From: Ullrich von Bassewitz (
Date: 2003-03-04 12:43:24

On Tue, Mar 04, 2003 at 01:20:06PM +0200, Marko Mäkelä wrote:
> Is "sizeof unsigned" a valid C expression?  I think (and gcc agrees with
> me) that you should use parentheses when determining the storage size of
> a data type, as in "sizeof (unsigned)".  If you omit the parentheses,
> the argument to sizeof should be a valid expression, which "unsigned" is
> not, as it cannot be the name of a constant or variable.

You are right, my code snippet was not correct.

    ra = (unsigned int*) malloc (size * sizeof *ra);        // works, but...
    ra = (unsigned int*) malloc (size * sizeof unsigned);   // ...does not.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.

Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-03-04 12:43:37 CET