Talk About Network

Google


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 > Re: Trouble wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 1066 of 1134
Post > Topic >>

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

by Prashu <prashanthkumar.chanda@[EMAIL PROTECTED] > Mar 28, 2008 at 07:20 PM

On Mar 20, 11:10 am, climber....@[EMAIL PROTECTED]
 wrote:
> 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: c...@[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.

Hi,
  I am not having having complete answer but have partly..

> #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?
  If we Put semicolon itself in the MACRO Definition.. even if we
forget putting semicolon in usage.. it wont effect the intended
result.. But if we forget as u know MACROs are expanded while
compilation .. it may leads to any problem...
-- 
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 Fri Jul 25 21:10:59 CDT 2008.