Re: Addendum to prior post (newbie crosspost)

From: Ronald Fenner (abbadon@mac.com)
Date: 06/25/02


>
> #define GET_OBJ_PERM(obj)       ((obj)->obj_flags.bitvector, (flag))
>
> Which results in:
>
> db.c: In function `parse_object':
> db.c:1485: `flag' undeclared (first use in this function)
> db.c:1485: (Each undeclared identifier is reported only once
> db.c:1485: for each function it appears in.)
> db.c:1485: warning: left-hand operand of comma expression has no effect
>
>
the reason you get the error for flag and not obj is in how the macro is
set up to be called.
GET_OBJ_PERM(obj) needs to be GET_OBJ_PERM(obj, flag) for it to work


> #define GET_OBJ_PERM(obj)       ((obj)->obj_flags.bitvector[(i)])
>
>
this also is not right unless the bitvector is an array which it
probably is not and from your other post you specified you were calling
the macro like this "GET_OBJ_PERM(obj+i) = t[9];". If for your original
post your macro was: GET_OBJ_PERM(obj) ((obj)->obj_flags.bitvector) this
should be correct though i'd would make sure that the perm obj affects
variable was named bitvector but also lets go with Viper's addition
about 128 bit then the macro should be GET_OBJ_PERM(obj, flag)
(IS_SET_AR((obj)->obj_flags.bitvector, flag)).
this is only suitable for checking wether a flag is set and should and
should probably be renamed OBJ_PERM(obj, flag).... For assignment there
are two ways to go, direct access to the variable(not necessarily good)
and change the macro to  GET_OBJ_PERM(obj) macro listed above. The
second method means you have access to the variable and you can assign
away IF it's not an array otherwise this would be the proper way to use
it:
GET_OBJ_PERM(obj+1)[0] = t[9]; This will assign t[9] to position 0 of
the array which if your file does not have all 4 integers for 128bit
then would suffice assuming you had cleared the array to all 0s.

Anyways i hope this helps you understand the use of macros in C better

Ron

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT