Keyword 'const' prevents to have only one format for function pointers
This ticket is the second part of #807 (closed) issue. We should have only one format for function pointers in S2OPC but with the keyword const, the new format wished is not compatible. This was observed in files :
- sopc_call_method_manager.h : in struct SOPC_MethodCallManager, line 110 and 122.
- libs2opc_client_cmds.h : in SOPC_ClientHelper_Initialize() function, line 401.
- libs2opc_client_common.h : in SOPC_ClientCommon_Initialize() function, line 75.
- sopc_pki.h : in SOPC_PKIProvider struct, line 75 and 89.
- sopc_crypto_profiles.h : in struct SOPC_CryptoProfile/struct SOPC_CryptoProfile_PubSub. (lines 191-202, 216-220)
We suggest as a solution, for example in sopc_pki.h :
const SOPC_PKIProvider_Free_Func pFnFree;
becomes SOPC_PKIProvider_Free_Func* const pFnFree;
, it implies a cast when this field is used, same case for the other files.
when SOPC_GCC_DIAGNOSTIC_IGNORE_CAST_CONST
appeared, the wrapped code will use the following syntax code, for example in sopc_pki.c :
SOPC_GCC_DIAGNOSTIC_IGNORE_CAST_CONST
*((SOPC_PKIProvider_Free_Func**) (&pki->pFnFree)) = &PKIPermissive_Free;
SOPC_GCC_DIAGNOSTIC_RESTORE
- We use parenthesis to ease the reading of the code.
- The type of pFnFree is SOPC_PKIProvider_Free_Func*
- We use a pointer to pFnFree in order to write in its memory
- We dereference pFnFree pointer to write in its memory the PKIPermissive_Free function.
Edited by Shahbaaz Ramjane