Intel C++ Compile Warnings

src\core\juce_PlatformDefs.h(74): warning #1879: unimplemented pragma ignored

src\core…/memory/juce_ByteOrder.h(105): warning #1879: unimplemented pragma ignored

src\core…/text/…/memory/juce_Atomic.h(205): warning #1879: unimplemented pragma ignored

#pragma intrinsic (_InterlockedExchange, _InterlockedIncrement, _InterlockedDecrement, _InterlockedCompareExchange, \ _InterlockedCompareExchange64, _InterlockedExchangeAdd, _ReadWriteBarrier)

Note that Intel C++ supports these intrinsics, search for “intel c++ intrinsics reference”

src\maths\juce_BigInteger.cpp(285): warning #1879: unimplemented pragma ignored

Still getting these

Ok, I’ll disable the pragmas for those functions. I guess they are all actually implemented though, judging by the fact that it’s only giving warnings about the pragmas, and not errors when the functions are used.

Hello Jules !

With Intel C++ and Visual Studio 2008, I have these warnings :

C:/SDK/juce2/modules/juce_audio_basics/../juce_core/system/../maths/juce_MathsFunctions.h(334): warning #1670: this pragma may only appear between declarations in the global scope or before any statements or declarations in a block scope 1> #pragma float_control (precise, on, push) 1> ^ 1> 1>C:/SDK/juce2/modules/juce_audio_basics/../juce_core/system/../maths/juce_MathsFunctions.h(361): warning #1670: this pragma may only appear between declarations in the global scope or before any statements or declarations in a block scope 1> #pragma float_control (pop) 1> ^
What does that mean ?

Hmm, I guess their compiler can’t deal with the fact that the function is templated.

Is it happier if you move those pragmas into the function, i.e.

[code]template
inline int roundToInt (const FloatType value) noexcept
{
#if JUCE_MSVC
#pragma optimize (“t”, off)
#pragma float_control (precise, on, push)
#endif

union { int asInt[2]; double asDouble; } n;
n.asDouble = ((double) value) + 6755399441055744.0;

#if JUCE_BIG_ENDIAN
return n.asInt [1];
#else
return n.asInt [0];
#endif

#if JUCE_MSVC
#pragma float_control (pop)
#pragma optimize (“”, on) // resets optimisations to the project defaults
#endif
}
[/code]

?

The compiler seems to be happier this way, thanks :wink:

Cool, thanks!

Anyway, if I compile again with the Visual C++ compiler, I get that now :

1>c:\sdk\juce2\modules\juce_core\system\../maths/juce_MathsFunctions.h(348) : warning C4081: expected 'newline'; found '(' 1>c:\sdk\juce2\modules\juce_core\system\../maths/juce_MathsFunctions.h(349) : warning C4177: #pragma 'float_control' should only be used at global scope or namespace scope 1>juce_PluginUtilities.cpp 1>c:\sdk\juce2\modules\juce_core\system\../maths/juce_MathsFunctions.h(348) : error C2156: pragma must be outside function 1> c:\sdk\juce2\modules\juce_core\system\../maths/juce_MathsFunctions.h(371) : see reference to function template instantiation 'int juce::roundToInt<double>(const FloatType) throw()' being compiled 1> with 1> [ 1> FloatType=double 1> ]

:mrgreen: :compiler wars:

sigh… Thanks, I’ve checked something that should work on both, albeit quite messily.

Hello Jules from TSC :mrgreen:

I have still C++ warnings when I’m compiling something with the INTEL compiler with Windows 7 + Visual Studio 2008. I have seen the change you have done, but it does not solve the problem. To get everything working, I need to define “__INTEL_COMPILER” in the Preprocessor Definitions of my project (I have Intel Compiler 2011, I imagine this definition may be done automatically with more recent versions maybe ?). Then, I have changed the part of the code which gives the issue :

[code]//==============================================================================
#if JUCE_MSVC
#pragma optimize (“t”, off)
#ifndef __INTEL_COMPILER
#pragma float_control (precise, on, push)
#endif
#endif

/** Fast floating-point-to-integer conversion.

This is faster than using the normal c++ cast to convert a float to an int, and
it will round the value to the nearest integer, rather than rounding it down
like the normal cast does.

Note that this routine gets its speed at the expense of some accuracy, and when
rounding values whose floating point component is exactly 0.5, odd numbers and
even numbers will be rounded up or down differently.

*/
template
inline int roundToInt (const FloatType value) noexcept
{
#ifdef __INTEL_COMPILER
#pragma float_control (precise, on, push)
#endif

union { int asInt[2]; double asDouble; } n;
n.asDouble = ((double) value) + 6755399441055744.0;

#if JUCE_BIG_ENDIAN
return n.asInt [1];
#else
return n.asInt [0];
#endif

}

#if JUCE_MSVC
#ifndef __INTEL_COMPILER
#pragma float_control (pop)
#endif
#pragma optimize ("", on) // resets optimisations to the project defaults
#endif

/** Fast floating-point-to-integer conversion.

This is a slightly slower and slightly more accurate version of roundDoubleToInt(). It works
fine for values above zero, but negative numbers are rounded the wrong way.

*/
inline int roundToIntAccurate (const double value) noexcept
{
#ifdef __INTEL_COMPILER
#pragma float_control (pop)
#endif

return roundToInt (value + 1.5e-8);

}[/code]

The compiler is telling me that the pragma stuff is only allowed inside a function and at the beginning of the function…

Ok, thanks for the heads-up. Messy to have to put a “pop” command at the start of an unrelated function, but I guess that’s the only way to make both compilers happy.