Reputation: 179
I would like to use the pragma
optimize in a function called image()
that I have created:
#pragma optimize("", off)
image();
#pragma optimize("", on)
Error 2 error C2156: pragma must be outside function C:....\Visual Studio 2010\Projects\ex4\ex4.cpp 1038
Error 4 error C2156: pragma must be outside function C:....\Visual Studio 2010\Projects\ex4\ex4.cpp 1040
I didn't find out how it would be possible to resolve that.
Upvotes: 1
Views: 1469
Reputation: 110698
Thes #pragma
s should be placed around the function definition of image
, not when you call it. Also, note that your order of off
and on
will disable optimizations for image
. For example:
#pragma optimize("", off)
void image()
{
// ...
}
#pragma optimize("", on)
This will disable the default optimizations (according to the /O
compiler option) for the duration of image
.
Upvotes: 3