• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: #define issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #define issues


  • Subject: Re: #define issues
  • From: Michael Rothwell <email@hidden>
  • Date: Thu, 21 Apr 2005 22:37:54 -0400

More parentheses!

#define SET_ENTRY( (m),(r),(c),(e)) (m[(r)*4+(c)] = (e))


Michael Rothwell
email@hidden

On Apr 17, 2005, at 12:47 AM, Cameron Hayne wrote:

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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: #define issues
      • From: Steve Checkoway <email@hidden>
References: 
 >Re: #define issues (From: Cameron Hayne <email@hidden>)

  • Prev by Date: Re: How to use a framework? (newbie)
  • Next by Date: NSNetServiceBrowser / NSNetService Hostname Lookup
  • Previous by thread: Re: #define issues
  • Next by thread: Re: #define issues
  • Index(es):
    • Date
    • Thread