Because our app has hard performance and memory constraints, our coding standards forbid the use of the default heap — ie, no malloc
, no default new
If your own "new" operator is not named "new" but differently (e.g. "myNew") you could use a "#define" in a way replacing "new" by rubbish:
#define new *+-/&
The pre-compiler would now replace a "new":
x = new mytype;
By the rubbish:
x = *+-/& mytype;
The advantage compared to a message at linking time is that this will generating a compiler message immediately while compiling the C++ file, not in the end when linking. You also see the line where the "new" is located.
The disadvantage is that you'll have to "#include" the file containing this "#define" in all C++ files in your project.