Latest tip getSmallestIntegerContainer() error


#1

On windows with VisualStudio 2010 SP1 if i call within any Component

getBounds().getSmallestIntegerContainer()

i get:

1>c:\devel\ctrlr\nightly\juce\modules\juce_graphics\geometry\juce_rectangle.h(701): error C2668: 'floor' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(136): could be 'double floor(double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(519): or       'float floor(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(567): or       'long double floor(long double)'
1>          while trying to match the argument list '(const int)'
1>          c:\devel\ctrlr\nightly\juce\modules\juce_graphics\geometry\juce_rectangle.h(691) : see reference to function template instantiation 'juce::Rectangle<ValueType> juce::Rectangle<ValueType>::getSmallestIntegerContainerWithType<int>(void) throw() const' being compiled
1>          with
1>          [
1>              ValueType=int
1>          ]
1>          c:\devel\ctrlr\nightly\juce\modules\juce_graphics\geometry\juce_rectangle.h(690) : while compiling class template member function 'juce::Rectangle<ValueType> juce::Rectangle<ValueType>::getSmallestIntegerContainer(void) throw() const'
1>          with
1>          [
1>              ValueType=int
1>          ]
1>          c:\devel\ctrlr\nightly\juce\modules\juce_graphics\images\juce_image.h(349) : see reference to class template instantiation 'juce::Rectangle<ValueType>' being compiled
1>          with
1>          [
1>              ValueType=int
1>          ]
1>c:\devel\ctrlr\nightly\juce\modules\juce_graphics\geometry\juce_rectangle.h(702): error C2668: 'floor' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(136): could be 'double floor(double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(519): or       'float floor(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(567): or       'long double floor(long double)'
1>          while trying to match the argument list '(const int)'
1>c:\devel\ctrlr\nightly\juce\modules\juce_graphics\geometry\juce_rectangle.h(703): error C2668: 'ceil' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(135): could be 'double ceil(double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(509): or       'float ceil(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(557): or       'long double ceil(long double)'
1>          while trying to match the argument list '(const int)'
1>c:\devel\ctrlr\nightly\juce\modules\juce_graphics\geometry\juce_rectangle.h(704): error C2668: 'ceil' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(135): could be 'double ceil(double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(509): or       'float ceil(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(557): or       'long double ceil(long double)'
1>          while trying to match the argument list '(const int)'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.46
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

A quick (but a dumb) fix seems to be:

getBounds().toFloat().getSmallestIntegerContainer()

#2

Strange - I use VC2010 and it all compiles for me (??)


#3

Strange indeed, just to make sure it’s not something of mine i added a line:

getBounds().getSmallestIntegerContainer ();

to the Introjucer MainWindow() constructor:

MainWindow::MainWindow()
    : DocumentWindow (IntrojucerApp::getApp().getApplicationName(),
                      Colour::greyLevel (0.6f),
                      DocumentWindow::allButtons,
                      false)
{
    setUsingNativeTitleBar (true);
    createProjectContentCompIfNeeded();
	getBounds().getSmallestIntegerContainer ();

the same error appears:

1>------ Build started: Project: The Introjucer, Configuration: Debug Win32 ------
1>Build started 30-Jul-13 11:40:33 PM.
1>ClCompile:
1>  jucer_MainWindow.cpp
1>c:\devel\juce\modules\juce_graphics\geometry\juce_rectangle.h(701): error C2668: 'floor' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(136): could be 'double floor(double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(519): or       'float floor(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(567): or       'long double floor(long double)'
1>          while trying to match the argument list '(const int)'
1>          c:\devel\juce\modules\juce_graphics\geometry\juce_rectangle.h(691) : see reference to function template instantiation 'juce::Rectangle<ValueType> juce::Rectangle<ValueType>::getSmallestIntegerContainerWithType<int>(void) throw() const' being compiled
1>          with
1>          [
1>              ValueType=int
1>          ]
1>          c:\devel\juce\modules\juce_graphics\geometry\juce_rectangle.h(690) : while compiling class template member function 'juce::Rectangle<ValueType> juce::Rectangle<ValueType>::getSmallestIntegerContainer(void) throw() const'
1>          with
1>          [
1>              ValueType=int
1>          ]
1>          c:\devel\juce\modules\juce_graphics\images\juce_image.h(349) : see reference to class template instantiation 'juce::Rectangle<ValueType>' being compiled
1>          with
1>          [
1>              ValueType=int
1>          ]
1>c:\devel\juce\modules\juce_graphics\geometry\juce_rectangle.h(702): error C2668: 'floor' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(136): could be 'double floor(double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(519): or       'float floor(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(567): or       'long double floor(long double)'
1>          while trying to match the argument list '(const int)'
1>c:\devel\juce\modules\juce_graphics\geometry\juce_rectangle.h(703): error C2668: 'ceil' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(135): could be 'double ceil(double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(509): or       'float ceil(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(557): or       'long double ceil(long double)'
1>          while trying to match the argument list '(const int)'
1>c:\devel\juce\modules\juce_graphics\geometry\juce_rectangle.h(704): error C2668: 'ceil' : ambiguous call to overloaded function
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(135): could be 'double ceil(double)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(509): or       'float ceil(float)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(557): or       'long double ceil(long double)'
1>          while trying to match the argument list '(const int)'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.80
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

#4

Ah, I see… It actually makes no sense to call that because it’s already an integer rectangle, which explains why nothing else in the codebase triggered the problem, but thanks - I’ll change it so that it compiles without any fuss!