Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Trouble with un...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 1066 of 1099
Post > Topic >>

Trouble with understanding #define macros from some source code. Please help.

by climber.cui@[EMAIL PROTECTED] Mar 20, 2008 at 01:10 AM

Hi All,
   I am trying to dissect some source code, but the C code there
really confuses me. The problem I had is the declaration of the macros
and the way they use them.
   While I would like to find out how  DEF_MARCEL_POSIX is defined, I
found the following in the source:

# define DEF_ALIAS_POSIX_OF_MARCEL(rtype, name, proto, args)

# define DEF_ALIAS_POSIX(rtype, name, proto, args)

#define DEF_ALIAS_MARCEL(rtype, name, proto, args) \
  TBX_FUN_ALIAS(rtype, MARCEL_NAME(name), \
    LOCAL_MARCEL_NAME(name), proto, args);             // why there is
a semi colon at the end?

#define DEF_MARCEL_POSIX(rtype, name, proto, args) \
  DEF_ALIAS_MARCEL(rtype, name, proto, args) \
  DEF_ALIAS_POSIX(rtype, name, proto, args) \
  DEF_ALIAS_POSIX_OF_MARCEL(rtype, name, proto, args) \
  rtype LOCAL_MARCEL_NAME(name) proto

-------------------------------------------------------------------------------------------------------------------------------------------
And in another file from the source, several occurrences of
DEF_MARCEL_POSIX, like this:

DEF_MARCEL_POSIX(int, attr_setstacksize, (marcel_attr_t *attr, size_t
stack), (attr, stack))
{
   if (stack > THREAD_SLOT_SIZE) {
      errno = EINVAL;
      return 1;
   }
   attr->__stacksize = stack;
   return 0;
}
....................
...................
DEF_MARCEL_POSIX(int, attr_getstacksize, (__const marcel_attr_t *
__restrict attr, size_t * __restrict stack), (attr, stack))
{
  *stack = attr->__stacksize;
  return 0;
}
-------------------------------------------------------------------------------------------------------------------------------------------
   I got completely lost here. What is DEF_MARCEL_POSIX defined to be?
Why it is declared as functions multiple times in the other file?

   Thanks in advance..

-tony
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.




 3 Posts in Topic:
Trouble with understanding #define macros from some source code.
climber.cui@[EMAIL PROTEC  2008-03-20 01:10:30 
Re: Trouble with understanding #define macros from some source c
Jonathan Leffler <jlef  2008-03-22 12:24:03 
Re: Trouble with understanding #define macros from some source c
Prashu <prashanthkumar  2008-03-28 19:20:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 17:08:51 CDT 2008.