I'm working with the CMCHTPC MediaFoundation headers, and they seem to work, but they give compiler warnings at several points that I'd like to get rid of. The culprit in most cases seems to be with enums such as the following:
TMF_Plugin_Type = (
MF_Plugin_Type_MFT = 0,
MF_Plugin_Type_MediaSource = 1,
MF_Plugin_Type_MFT_MatchOutputType = 2,
MF_Plugin_Type_Other = DWORD(-1)
);
No matter how that last value is defined, as DWORD(-1)
or DWORD($FFFFFFFF)
or simply as $FFFFFFFF
, the compiler always replies:
W1012 Constant expression violates subrange bounds
Is there any way to fix this definition without specifically suppressing that warning in the compiler? (Note that {$R-}
does not work; this turns off range checking at runtime, but not at compile time.)
You can declare it just as -1 and give a {$Z4} to tell the compiler to use 4 bytes for this enum:
{$Z4}
type
TMF_Plugin_Type = (
MF_Plugin_Type_MFT = 0,
MF_Plugin_Type_MediaSource = 1,
MF_Plugin_Type_MFT_MatchOutputType = 2,
MF_Plugin_Type_Other = -1);
It may as well work without the compiler directive. The docs say:
To assign an ordinality to a value, follow its identifier with = constantExpression, where constantExpression is a constant expression that evaluates to an integer.
An Integer of value -1 is internally represented as 4 bytes. So either way should work.
Update: I rechecked and the compiler directive is indeed necessary (unless you set the similar option in the project options).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With