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.


|