C macro

I am currently reading Lua source. I find the following macro ,
#define l_tg(x) (x) used in this form
static int math_abs (lua_State *L) {
lua_pushnumber(L, l_tg(fabs)(luaL_checknumber(L, 1)));
return 1;
}
What is the real reason for macro l_tag(XXX)?

(By the way, why do you write 'XX' for '##' ?)
> I very much understand this one. It is concatenation, but the there
> first macro lacked that ability.

Because the first macro does not need that ability.
With the first macro, l_tg(atan2) translates to (atan2),
a function that works with doubles.
That is probably what you want if you use the first macro.

With the second macro, l_tg(atan2) translates to (atan2f),
a function that works with floats.
which is probably what you want if you use the second macro.

If you wanted to use functions that work with long doubles,
you would have used yet another macro:

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!