"zh*********@gmail.com" <zh*********@gmail.com> writes:
Before I thought C is simple and convient , but now I dont think
so.There is really some ugly thing in C.Today I see some macro
declaration like this:
void va_end (va_list); /* Defined in gnulib */
#define va_end(AP)
Even if we dont consider what va_end do,but doesnt it cause some name
confliction as a result of its two appearances?
Many times, a library will provide both a function (as required by the
standard), and a function-like macro that does the same thing
(explicitly allowed by the Standard). In the case of va_end(), the
Standard specifically allows va_end() to be either a function /or/ a
macro /or/ both.
With code like the above, if you call va_end(ap), then you'll invoke
the macro, which apparently does nothing (but still must be provided,
per the Standard). If you call (va_end)(ap), you'll be guaranteed to
get the function (which probably also does nothing, in your
implementation).
However, (va_end)(ap) is explicitly not supported by the Standard, so
I don't really know why they bothered to provide a real function. For
other Standard functions that are allowed to be macros, though, that
style is the usual way to ensure that you really call a function, not
invoke a macro.
-Micah