No clear course of action for dealing with C / C++ header translations with enums that really are greater than 2147483647.
Original Reporter info from Mantis: Akira1364
-
Reporter name:
Original Reporter info from Mantis: Akira1364
- Reporter name:
Description:
I'm aware that this technically has never been valid (for reasons I'm not entirely clear about) in Pascal, but even if it would wrap around on the actual numerical value, FPC did at least display the "textual" name of these enums. For example:
program PascalExample;
type
// ↓↓↓ reduced version of the actual enum for example purposes
TVkAccessFlagBits = (
VK_ACCESS_RESERVED_31_BIT_KHR = $80000000
);
begin
WriteLn(TVkAccessFlagBits.VK_ACCESS_RESERVED_31_BIT_KHR);
end.
would print exactly "VK_ACCESS_RESERVED_31_BIT_KHR".
More importantly though, it's not a "mistake" in the sense that it's just a literal, correct translation of the value from a C header, which in that context is valid, and doesn't outwardly seem like it should have any reason to not translate directly to Pascal. E.G. the C++ equivalent is completely fine and works correctly in all scenarios:
#include &LtPos;iostream>
// ↓↓↓ reduced version of the actual enum for example purposes
enum TVkAccessFlagBits {
VK_ACCESS_RESERVED_31_BIT_KHR = 0x80000000
};
int main() {
// ↓↓↓ no wraparound, proper numerical value is preserved.
std::cout << TVkAccessFlagBits::VK_ACCESS_RESERVED_31_BIT_KHR << std::endl;
}
I may be oversimplifying things, but it seems like something like a {$Z8} compiler switch would make more sense than just maintaining the somewhat arbitrary High(LongInt) cap, which evidently isn't quite compatible with everything it should be.
Steps to reproduce:
Compile provided snippets, or similar code.
Mantis conversion info:
- Mantis ID: 36175
- OS: 10
- OS Build: Windows
- Build: 43194
- Platform: x86_64
- Version: 3.3.1
- Monitored by: » Vincent (Vincent Snijders)