Re: #define issues
Re: #define issues
- Subject: Re: #define issues
- From: Cameron Hayne <email@hidden>
- Date: Sun, 17 Apr 2005 00:47:13 -0400
On 4/16/05 6:58 AM, "Aaron Boothello" <email@hidden> wrote:
> typedef double matrix[16];
> #define SET_ENTRY(m,r,c,e) (m[r*4+c] = e)
>
> the 'macro' is called as follows (example):
> SET_ENTRY(ret,1,1,4.5); //where ret is of type matrix
>
> error generated is:incompatible types in assignment.
Well, there is nothing wrong in principle with this code.
I can compile and run the following program with no problem using gcc 3.3:
-------------------------
#include <stdio.h>
typedef double matrix[16];
#define SET_ENTRY(m,r,c,e) (m[r*4+c] = e)
matrix ret;
int main()
{
SET_ENTRY(ret,1,1,4.5);
printf("value set was %f\n", ret[5]);
return 0;
}
-------------------------
So probably your problem is due to something else sneaking in there and
redefining "matrix" or something.
In any case, the standard way to debug a problem with the preprocessor is to
look at the C code after the preprocessor has done its thing.
E.g. via 'gcc -E'
It is usually obvious what is causing the trouble once you do that.
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden