function - Understanding nested macro syntax in C -
i'm trying understand macros in c , need help. i'm new coding , appreciate on understanding.
- does syntax of macro definitions in c depend on compiler or there c standard definitions aren't specific compiler?
- the macros executed c preprocessing(cpp) correct? http://tigcc.ticalc.org/doc/cpp.html
you can add macro definitions depending on build environments set correct?
i'm trying understand code i'm confused. first line of code sets function macro cat concatenates , b right?
the second line creates function qte takes in name i'm not quite sure single hash in macro...?
the third line i'm unsure because i've never seen function function definition. concatenating s_ , generic , placing value input function using function replacement sel(generic)?
in fourth line class, _, , type not defined substitute other 3 macro objects contained within 3 functions of fourth lines code correct?
#define cat(a,b) a##b #define qte(name) #name #define sel(generic) cat(s_,generic) #define export(class, generic, type) classmethod(class, sel(generic), cat(_, generic), type) ;
converting comment answer.
the basic syntax of macros standard across compilers.
the macros can interpreted separate c preprocessor program (traditionally called
cpp
), or integrated part of main compiler. these days, compilers use integrated preprocessor rather standalone preprocessor, variety of complex reasons.yes.
multiple parts:
- the hash operator converts argument string.
- the sel macro prefixes symbol passed argument
s_
. - the
_
inexport
'letter';class
c++ keyword, used parameter name here (there aren't keywords when preprocessor running). - we've no idea
classmethod()
does, given series of modified arguments.
given:
export(aaa, bbb, ccc)
you output from:
classmethod(aaa, s_bbb, _bbb, ccc);
the added semicolon in macro definition export
bit dubious; normally, you'd invoke:
export(aaa, bbb, ccc); // semicolon after invocation
and not include semicolon in macro definition.
Comments
Post a Comment