Minor compiler warning in blitToWindow


#1

Building JUCE 1.30 on OS X for Intel gives me a compiler warning in juce_mac_Windowing in the function blitToWindow.

blitToWindow starts with this code:

[code]#ifdef JUCE_LITTLE_ENDIAN
int lineStride, pixelStride;
uint8* const imageData = lockPixelDataReadWrite (0, 0, getWidth(), getHeight(), lineStride, pixelStride);

    const int w = getWidth();

    for (int y = 0; y < getHeight(); ++y)
    {
        uint32* const lineData = (uint32*) (imageData + lineStride * y);

        for (int x = 0; x < w; ++x)
            lineData[x] = CFSwapInt32BigToHost (lineData[x]);
    }

This gives you the warning “name lookup of ‘y’ changed”. This is because blitToWindow takes “int y” as a parameter and “int y” is declared again within the for loop.

So I changed it to this:

[code]#ifdef JUCE_LITTLE_ENDIAN
int lineStride, pixelStride;
uint8* const imageData = lockPixelDataReadWrite (0, 0, getWidth(), getHeight(), lineStride, pixelStride);

    const int w = getWidth();

    for (int tempY = 0; tempY < getHeight(); ++ tempY)
    {
        uint32* const lineData = (uint32*) (imageData + lineStride * tempY);

        for (int x = 0; x < w; ++x)
            lineData[x] = CFSwapInt32BigToHost (lineData[x]);
    }

[/code]

that is, replacing “y” with “tempY”, which gets rid of the warning.

Not the end of the world, but I figured it was worth mentioning.

Matt


#2

Ah, nice one matt. I always like to tidy up all the warnings, thanks.


#3