I can't compile parts of the SDL 1.2 (here ) with the Visual C++ compiler. In particular, this part (lines 3, 16):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Inside BinaryFile.cpp
1 Uint64 InputBinaryFile::read(std::size_t n)
3 Uint64 value = 0; // No suitable constructor exists to convert from 'int' to 'Uint64'
4 std::size_t shift = 0;
7 if (bufferSize == 0)
9 if (!in.read(reinterpret_cast<char*>(&bufferData), 1))
11 bufferData = 0;
13 bufferSize = 8;
15 std::size_t rbits = std::min(bufferSize, n);
16 value |= (bufferData & ~(~Uint64(0) << rbits)) << shift; // Cannot cast from 'int' to 'Uint64' via functional-style cast
The compiler error:
1>...\C++\Projects\Brumbrumrally\src\BinaryFile.cpp(48,18): error C2440: 'initializing': cannot convert from 'int' to 'Uint64'
1>...\Code\C++\Projects\Brumbrumrally\src\BinaryFile.cpp(48,18): message : No constructor could take the source type, or constructor overload resolution was ambiguous
Uint64 isn't a language type. It's defined in \SDL-1.2\include\SDL_stdinc.h
1 2 3 4 5 6 7 8 9 10 11
typedef int64_t Sint64;
typedef uint64_t Uint64;
/* This is really just a hack to prevent the compiler from complaining */
} Uint64, Sint64;
Any suggestions for fixing this?
I thought to specify a constructor for conversion from int but it's an anonymous class and that didn't work.
That would have the same problem, since it's just a typedef, no? (Very strong chance I'm wrong; I'm surprised this is even an issue in the first place). If just using std::uint64_t is the solution, why is the compiler being stricter for a typedef?
The error messages indeed suggest that Uint64 is being defined as a struct which means SDL_HAS_64BIT_TYPE has not been defined for some reason.
The comment says the struct is "just a hack to prevent the compiler from complaining" so I don't think it's actually meant to be used. It's not going to work as a fallback replacement for a 64-bit integer type.
I guess you could make the effort and write code that handles Uint64 being a struct but the project "Brum Brum Rally" that you're trying to build certainly doesn't (I know because I am the author).
You do have support for 64-bit integers on your computer, I'm almost certain, so the question is why SDL_HAS_64BIT_TYPE has not been defined.