Unable to compile after updating


#1

I won’t bore you with the details of my program. The thing is that it compiled and worked fine earlier today on this same computer, but after I updated to the latest tip (about an hour ago) I am getting this:

In file included from ../Source/juce/juce_amalgamated.cpp:891,
                 from ../Source/JuceSource.cc:12:
../Source/juce/juce_amalgamated.h: In member function ‘Type juce::Atomic<Type>::operator-=(Type) [with Type = void*]’:
../Source/juce/juce_amalgamated.cpp:1693:   instantiated from ‘void juce::juce_testAtomicType(Type) [with Type = void*]’
../Source/juce/juce_amalgamated.cpp:1726:   instantiated from here
../Source/juce/juce_amalgamated.h:5802: error: cast from ‘void*’ to ‘juce::int32’ loses precision
../Source/juce/juce_amalgamated.h: In member function ‘Type juce::Atomic<Type>::operator-=(Type) [with Type = int*]’:
../Source/juce/juce_amalgamated.cpp:1693:   instantiated from ‘void juce::juce_testAtomicType(Type) [with Type = int*]’
../Source/juce/juce_amalgamated.cpp:1727:   instantiated from here
../Source/juce/juce_amalgamated.h:5802: error: cast from ‘int*’ to ‘juce::int32’ loses precision
make: *** [build/intermediate/Debug/JuceSource.o] Error 1

It seems like something assumes that pointers are 32-bit integers even though I’m running a 64-bit linux (kubuntu 10.04).


#2

I’m baffled by why the compiler won’t accept that - I’d have thought that it’d give a warning at most. (And it works for me in a 64-bit gcc build)

If you replace it with a more cunning template-based approach, does this compile?

template <typename Type> static Type juce_negateValue (Type n) throw()   { return -n; }
template <typename Type> static Type* juce_negateValue (Type* n) throw() { return (Type*) -(pointer_sized_int) n; }

template <typename Type>
inline Type Atomic<Type>::operator-= (const Type amountToSubtract) throw()
{
    return operator+= (juce_negateValue (amountToSubtract));
}