Блог пользователя harhrayr

Автор harhrayr, 13 лет назад, По-английски

Does anybody know how to expand macros in visual c++ ?

For example.

#define FOR(i, n) for(i = 0; i < n; ++i)

It's faster to write FOR(i, n) than for(i = 0; i < n; ++i), but for(i = 0; i < n; ++i) is more

beautiful and comfortable, so I want to expand FOR(i, n) pressing a button or buttons. Is there

any extension for visual c++ 2010 or 2012 ?

Thanks.

  • Проголосовать: нравится
  • +19
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

It's called code snippets, but I don't know how to use them in Visual C++. Try to google it.

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

in Microsoft Visual studio Express 2012 write "for" and double tap the "TAB" button to automatically insert the for loop body for (int i = 0; i < length; i++) {

}

it is like the above after that you can change the "length" with anything you want

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

If you get used to the long version, it will be faster to write than short.

  • »
    »
    13 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    I think that the time spent typing in the solution is negligible altogether in comparison to the time spent reading, thinking, testing and debugging. Also, most people here are fast typists anyway. Thus, in my opinion, shorthand macros like FOR succeed only in making the code less readable, which leads to harder debugging.