1

Topic: Macroes in C language ++

Dear colleagues where it is possible to read explicitly about macroes in C language ++?

2

Re: Macroes in C language ++

Hello, RussianFellow, you wrote: RF> Dear colleagues where it is possible to read explicitly about macroes in C language ++? https://msdn.microsoft.com/ru-ru/library/y4skk93w.aspx

3

Re: Macroes in C language ++

Hello, RussianFellow, you wrote: RF> Dear colleagues where it is possible to read explicitly about macroes in C language ++? http://en.cppreference.com/w/cpp/preprocessor

4

Re: Macroes in C language ++

Hello, RussianFellow, you wrote: RF> Dear colleagues where it is possible to read explicitly about macroes in C language ++? If here it you will master, it is possible to consider that understood explicitly)

5

Re: Macroes in C language ++

Hello, RussianFellow, you wrote: RF> Dear colleagues where it is possible to read explicitly about macroes in C language ++?  does not recommend, instead of them a constant, listing and so forth, here there and to esteem. And as a whole here answers to many your questions: How to study a C ++ Tomorrow you search on the Internet for the book of Straustrup. A C Programming language ++. @# if you will understand nothing. Then you study STL from cover to cover. Then you cram, @#, you learn by heart the C standard ++ 0x that from teeth recoiled. When you will write the first sorting with the help template, on the way studying inheritance, encapsulation and polymorphism, you download and you study any  a development environment, I recommend g ++. As you will alter sorting that there was it worked with any of classes, and not just with numbers, you can go further - you are waited by the fascinating world @#. Preprocessors, multiple inheritance, pointers on function, , manual garbage collection, o-o-very long compilation. A suction at  @# / it is simple losers of type  or sisjarp/dzhava-peasants who write  in convenient  and receive high ratings does not keep itself waiting and through a floor of year you will already hang in top  that any employee Google will leak at one listing of all your prize-winning T-shirts.

6

Re: Macroes in C language ++

Hello, anonymouse2, you wrote: RF>> Dear colleagues where it is possible to read explicitly about macroes in C language ++? A> If here it you will master, it is possible to consider that understood explicitly) Too thought that saw everything when them understood. Then understood that it is unpretentious changeover when got acquainted with high-grade macroes with a recursion, arithmetics, multiline record, and agitation  with , here where there was a hardcore. But it unfortunately other language where not castrated macroes.

7

Re: Macroes in C language ++

Hello, RussianFellow, you wrote: RF> Dear colleagues where it is possible to read explicitly about macroes in C language ++? I now will tell all about macroes. 1. Macroes without parameters. It is a thing absolutely simple: #define MESSAGE "Hello, world" Everywhere where we write MESSAGE, the compiler substitutes an appropriate line printf ("%s\n", MESSGE);//Prints Hello, world 2. Macroes with the parameters, containing expressions #define max (x, y) ((x)> (y)? (x): (y)) What for we in a macro body write arguments in brackets, and a body in brackets? Because if expression the priority of operators can appear more low, than a priority of operators in the macro will be transferred a macro, and the result can appear unexpected. It  to explain such example: #define add2 (x) x + 2 If to cause, as add2 (3+4), it turns out 3+4*2, and we meant (3+4 *2 There is however a problem which is not treated by brackets. We admit, we transferred to a macro max parameter x ++. Then there is a chance that it will be calculated twice, and  increases x on 1. It not that we would like. In a C ++ from it  it is better to use . 3. The macroes, which call looks, as function. #define FOOBAR (x) do {foo (x); bar {x);} while (0) what for to wrap a body in do {...} while (0)? We present that we did not make it, and called a macro here so: if (flag) FOOBAR (1); else SomethingElse (); Without do... while it turns out here so: if (flag) foo (1); bar {1); else SomethingElse (); else it is explicit not . In this case it will not be compiled, and if instead of if' to use such a macro in a cycle, the operator gets to a cycle, instead of the second only . Zavorachivanie bodies in do... while solves this problem. Attention, a semicolon after while (0) it is not necessary! 4. Macroes which are not located in single line. It is simple: #define FOOBAR (x) \do {\foo (x); \bar {x); \} while (0) Sign \should be the latest in line, a gap after it we do not admit. 5. Difficult macroes which sometimes meet in different projects. They simply should not be used.

8

Re: Macroes in C language ++

Hello, Vain, you wrote: RF>>> Dear colleagues where it is possible to read explicitly about macroes in C language ++? A>> If here it you will master, it is possible to consider that understood explicitly) V> Too thought that saw everything when them understood. V> then understood that it is unpretentious changeover when got acquainted with high-grade macroes with a recursion, arithmetics, multiline record, and agitation  with , here where there was a hardcore. But it unfortunately other language where not castrated macroes. Sishnye macroes are a text substitution, no more. It is strange to expect from them any magic

9

Re: Macroes in C language ++

Hello, Pzz, you wrote: Pzz> Hello, RussianFellow, you wrote: RF>> Dear colleagues where it is possible to read explicitly about macroes in C language ++? Pzz> I now will tell all about macroes. Did not tell about  and concatenation. But and so - not laziness was to write? Or ? : the HARDWARE generally is able to use Google? In the same place under the first link all . , the HARDWARE is simple . It MFC-shnyj a forum so generally , for example

10

Re: Macroes in C language ++

Hello, Kodt, you wrote: Pzz>> I now will tell all about macroes. It you well joked. Pzz>> 5. Difficult macroes which sometimes meet in different projects. They simply should not be used. Microsoftovsky semistandard _T ("string-literal") - already uneasy. Because in it becomes or concatenation of lexemes does not become.  any debug macroes - TRACE there - even less simple. Too simply enough Old kind yourDLLAPI - idle time, but with the conditional compilation. Here macroes with... - here is more cheerful

11

Re: Macroes in C language ++

Hello, Kodt, you wrote: slightly more difficult, than do-while Become either on , or on . My favourite: (a problem with an asterisk - to finish that worked not only in GNU, but also in MSVC) #define PP_NARG (...) \PP_NARG _ (__ VA_ARGS __, PP_RSEQ_N ()) #define PP_NARG _ (...) \PP_ARG_N (__ VA_ARGS __) #define PP_ARG_N (\_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \_11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \_21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \_31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \_41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \_51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \_61, _62, _63, N...) N #define PP_RSEQ_N () \63,62,61,60, \59,58,57,56,55,54,53,52,51,50, \49,48,47,46,45,44,43,42,41,40, \39,38,37,36,35,34,33,32,31,30, \29,28,27,26,25,24,23,22,21,20, \19,18,17,16,15,14,13,12,11,10, \9, 8, 7, 6, 5, 4, 3, 2, 1, 0

12

Re: Macroes in C language ++

Hello, Kodt, you wrote: If , tell , WHY >#define PP_CAT (x, y) PP_CAT _ (x, y) >#define PP_CAT _ (x, y) x##y//why not at once here so Likely that arguments revealed?>> Any debug macroes - TRACE there - even less simple. M>> too simply enough it is slightly more difficult, than do-while Become either on , or on . Do not swear

13

Re: Macroes in C language ++

Hello, Marty, you wrote: M> : the HARDWARE generally is able to use Google? In the same place under the first link all . , the HARDWARE is simple . It MFC-shnyj a forum so generally , for example to use Google I be able. But one business Google, and another matter - councils of other programmers.

14

Re: Macroes in C language ++

Hello, Pzz, you wrote: Pzz> Hello, RussianFellow, you wrote: RF>> Dear colleagues where it is possible to read explicitly about macroes in C language ++? Pzz> I now will tell all about macroes. Pzz> 1. Macroes without parameters. It is a thing absolutely simple:... Pzz> 5. Difficult macroes which sometimes meet in different projects. They simply should not be used. I want to note that macroes preprocessor processes. And to you absolutely hinders nothing to process source codes the preprocessors. For example as it  qt. Or even so main.cpp.php - (php)-> main.cpp - (c ++)-> main

15

Re: Macroes in C language ++

Hello, Kodt, you wrote: "it is not necessary to use them"? Yes. Taking into account my audience.

16

Re: Macroes in C language ++

Hello, Marty, you wrote: M> But and so - not laziness was to write? Or ? Not laziness. M> : the HARDWARE generally is able to use Google? In the same place under the first link all . , the HARDWARE is simple . It MFC-shnyj a forum so generally , for example I so do not think.

17

Re: Macroes in C language ++

Hello, kov_serg, you wrote: Pzz>> 5. Difficult macroes which sometimes meet in different projects. They simply should not be used. _> I want to note that preprocessor processes macroes. _> and to you absolutely hinders nothing to process source codes the preprocessors. For example as it  qt. _> Or even so main.cpp.php - (php)-> main.cpp - (c ++)-> main Following this way, it is better not to show off, and fairly to make domain-specific language which is compiled in Si. But the question was not about DSL, and about macroes.

18

Re: Macroes in C language ++

Hello, RussianFellow, you wrote: RF> Dear colleagues where it is possible to read explicitly about macroes in C language ++? Read  the dead...

19

Re: Macroes in C language ++

Hello, kov_serg, you wrote: _> I Want to note that preprocessor processes macroes. _> and to you absolutely hinders nothing to process source codes the preprocessors. For example as it  qt. _> Or even so main.cpp.php - (php)-> main.cpp - (c ++)-> main There is here such piece: https://www.python.org/about/success/cog/