Issue
in my c++ code(VS2013) which migration maybe from VC6, there is a warning C4177: #pragma 'float_control' should only be used at global scope or namespace scope for code below:
bool ClassNameHere::FunctionNameHere(Process::FileInfo *fileInfo, RBF &File, PaveConfig &cfg)
{
//some code here
#pragma float_control( strict, on, push )
// Calculate sample interval.
double dResolution = 1000000 / odo.dOdoFactor; // (1.0 / odo.dOdoFactor) * 1000000.0;
double dPulsesPerElevInterval = (DWORD)cfg.fSampleInterval / dResolution;
// Small fix for test mode surveys
if (odo.dOdoFactor != 1)
dPulsesPerElevInterval = DWORD(1.0 + dPulsesPerElevInterval);
//some code here
//....
//...
dElevInterval = dElevInterval / 1000.0;
dAccelInterval = dAccelInterval / 1000.0;
#pragma float_control(pop)
return true;
}
does somebody know how to handle the warning? If I just move these #pragma float_control out of function, and put them in so call global scope. Where should I put? or is there any other solution? thanks,
Solution
The documentation is pretty dire about what will happen if you ignore the warning,
The pragma will not be valid until global scope is encountered after the current scope.
So it looks like your only option is to move the pragma outside of the function.
If you don't care about some code here
getting included, put the push ahead of the function and the pop after.
#pragma float_control( strict, on, push )
bool ClassNameHere::FunctionNameHere(Process::FileInfo *fileInfo, RBF &File, PaveConfig &cfg)
{
//some code here
// code we care about here
}
#pragma float_control(pop)
If you do care about some code here
getting included, make another function containing the code currently between the push and pop, surround this new function with push and pop, and call the new function from FunctionNameHere
. Something like
#pragma float_control( strict, on, push )
bool ClassNameHere::HelperForFunctionNameHere (Process::FileInfo *fileInfo, RBF &File, PaveConfig &cfg)
{
// code we care about here
}
#pragma float_control(pop)
bool ClassNameHere::FunctionNameHere(Process::FileInfo *fileInfo, RBF &File, PaveConfig &cfg)
{
//some code here
return HelperForFunctionNameHere(fileInfo, File);
}
Answered By - user4581301 Answer Checked By - David Marino (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.