The Pitfalls Behind Macro Definitions: Anomalous Behavior in C++ Code
Last Saturday, a colleague asked me to help look at a piece of code that was behaving strangely. To simplify the explanation, I have distilled the core logic as follows: #include <algorithm>#include <iostream>#include <iterator> #define FS 20 // Sampling rate#define SECS 5 // Seconds#define BUF_LEN FS*SECS // Buffer length#define CHANNELS 5 // Number of channels … Read more