ftinspect: compile warning on MSVC about int->FTC_FaceID conversion
MSVC complains when compiling ftinspect code:
engine.cpp(265): warning C4312: 'reinterpret_cast': conversion from 'T' to 'void *' of greater size
with
[
T=int
]
The affected code is like:
FTC_FaceID ftcFaceID = reinterpret_cast<void*>
(faceIDMap.value(FaceID(fontIndex,
0,
0)));
.....
ftcFaceID = reinterpret_cast<void*>(faceCounter);
where faceCounter
and value return from faceIDMap.value
are all int
.
There're two possible solutions:
- Use
intptr_t
in favor ofint
. This enables 8 bytes long face id on 64 bit machines. ThefaceIDMap
andfaceCounter
would be redefined (maybe we need type aliasing); - Cast
int
tointptr_t
at all sites of conversion. This can ensure consistent behavior on 32 and 64 bit machines.
Which solution should be preferred?