Macros and strings

Nasza ocena:

3
Wyświetleń: 665
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Macros and strings - strona 1 Macros and strings - strona 2 Macros and strings - strona 3

Fragment notatki:

Macros and strings  Formal parameters are not replaced within quoted strings: #define M(iks) printf("iks=%d", iks); int v2=789; M(v2) /* the result: iks=789 */  If a parameter name is preceded by a # in the replacement text, the combination will be expanded into a quoted string with the parameter replaced by the actual argument  Example: #define dprint(expr) \ printf(#expr " = %lf\n", expr) ... dprint(x/y); results in printf("x/y" " = %lf\n", x/y); printf("x/y = %lf\n", x/y);  The preprocessor operator ## provides a way to concatenate actual arguments during macro expansion  If a parameter in the replacement text is adjacent to a ## , the parameter is replaced by the actual argument  The ## and surrounding white space are removed, and the result is re-scanned  Example: if the macro paste concatenates its two arguments: #define paste(f1, f2) f1 ## f2 then paste(va, r5) = 89; creates an assignment: var5 = 89;  Be carefull... More details in the documentation ... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz