Subverting Type Safety
I have a library that has two versions of a structure, an older version and a new extended version.
Functions are described in the header file to take the older version and the manufacturer advises to use the newer version of the structures and to cast the reference to satisfy the compile time type checking.
This seems to defeat jnaerator/bridJ. Whilst there are no problems in C/C++ with casting pointers, in Java, templated Pointer<> classes cannot be cast e.g. Pointer cannot be cast to Pointer
Any advice on how to handle this?
=== Excerpt from header file ===
// QCam_Settings is obsolete. Use QCam_SettingsEx in conjunction with QCam_CreateCameraSettingsStruct,
// QCam_Err QCam_InitializeCameraSettings and QCam_ReleaseCameraSettings
typedef struct
{
unsigned long size;
unsigned long _private_data[ 64 ];
}
QCam_Settings;
typedef struct
{
unsigned long size; // Filled by the initialization routine
QCam_settings_id _pSettingsID; // pointer to the camera settings ID
unsigned long *_private_data; // Pointer to a camera settings array
}
QCam_SettingsEx, *pQCam_SettingsEx;
// Example function specifying old version QCam_Settings
extern QCam_Err QCAMAPI QCam_SetParam64
(
QCam_Settings* pSettings,
QCam_Param64 paramKey,
UNSIGNED64 value
);
// Example function specifying new version QCam_SettingsEx
extern QCam_Err QCAMAPI QCam_CreateCameraSettingsStruct
(
QCam_SettingsEx* pSettings
);
// Example code from manufacture showing use of casting to pass new version
// QCam_SettingsEx to function with signature for old version QCam_Settings
// Create and allocate the settings structure
QCam_SettingsEx mySettings;
QCam_CreateCameraSettingsStruct(&mySettings);
// Change mySettings:
QCam_SetParam64( (QCam_Settings*) &mySettings, qprm64Exposure, 100000000);
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4