function - Understanding nested macro syntax in C -


i'm trying understand macros in c , need help. i'm new coding , appreciate on understanding.

  1. does syntax of macro definitions in c depend on compiler or there c standard definitions aren't specific compiler?
  2. the macros executed c preprocessing(cpp) correct? http://tigcc.ticalc.org/doc/cpp.html
  3. you can add macro definitions depending on build environments set correct?

  4. 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.

  1. the basic syntax of macros standard across compilers.

  2. 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.

  3. yes.

  4. multiple parts:

    • the hash operator converts argument string.
    • the sel macro prefixes symbol passed argument s_.
    • the _ in export '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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -