Macro Evil in C++ Code

The C++ language opens extensive opportunities to go without macros. So let’s try to use macros as seldom as possible!

Macro Evil in C++ Code

by Andrey Karpov

From the article:

The ATL library provides such macros, as A2W, T2W and so on for string conversion. However, few people know that it is very dangerous to use these macros inside loops. Within the macro, a call to the alloca function occurs, which will repeatedly allocate memory on each loop iteration on the stack. A program makes show that it works correctly. Once a program starts to handle longer strings and the number of loop iterations increases, the stack can just end at the most unexpected moment.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.