FROM : Michael Rothwell
DATE : Fri Apr 22 04:37:54 2005
More parentheses!
> #define SET_ENTRY( (m),(r),(c),(e)) (m[(r)*4+(c)] = (e))
Michael Rothwell
<email_removed>
On Apr 17, 2005, at 12:47 AM, Cameron Hayne wrote:
On 4/16/05 6:58 AM, "Aaron Boothello" <<email_removed>> 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_removed>)
Hayne of Tintagel
DATE : Fri Apr 22 04:37:54 2005
More parentheses!
> #define SET_ENTRY( (m),(r),(c),(e)) (m[(r)*4+(c)] = (e))
Michael Rothwell
<email_removed>
On Apr 17, 2005, at 12:47 AM, Cameron Hayne wrote:
On 4/16/05 6:58 AM, "Aaron Boothello" <<email_removed>> 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_removed>)
Hayne of Tintagel
| Related mails | Author | Date |
|---|---|---|
| Aaron Boothello | Apr 16, 09:44 | |
| Justin Spahr-Summe… | Apr 16, 10:09 | |
| Aaron Boothello | Apr 16, 10:13 | |
| p3consulting | Apr 16, 10:25 | |
| Aaron Boothello | Apr 16, 10:35 | |
| Justin Spahr-Summe… | Apr 16, 11:10 | |
| Aaron Boothello | Apr 16, 12:58 | |
| Cameron Hayne | Apr 17, 06:47 | |
| Andrew White | Apr 18, 05:54 | |
| Michael Rothwell | Apr 22, 04:37 | |
| Steve Checkoway | Apr 26, 07:04 |






Cocoa mail archive

