Should #pragma optimize
reside in B.h
,
class B{
#pragma optimize( "", off )
public: void f();
#pragma optimize( "", on )
};
or B.cpp
#include "B.h"
#pragma optimize( "", off )
void B::f(){
}
#pragma optimize( "", on )
or both?
There is a useful description from the official site ( https://learn.microsoft.com/en-us/cpp/preprocessor/optimize?view=vs-2019 ), but I am not sure what it means:
The optimize pragma must appear outside a function and takes effect at the first function defined after the pragma is seen.
What does the "defined" mean - declaration or implementation?
Similar questions / references
- Why #pragma optimize("", off) - why use it.
- "Function has no address" despite disabled optimization (/Od) - why location matters.