1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| #ifdef __cplusplus
#define STATIC_CAST(type,val) static_cast<type>(val)
#define VOIDETOILE_CAST(type, ptrvoid) static_cast<type>(ptrvoid)
// + reinterpret_cast, const_cast, etc.
#else
#define STATIC_CAST(type,val) ((type)(val))
#define VOIDETOILE_CAST(type, ptrvoid) (ptrvoid)
/* + reinterpret_cast, const_cast, etc. */
#endif
/* ... */
int A = 10;
/* Première instruction avec un static_cast */
float B = STATIC_CAST(float, A);
int *ptrC = VOIDETOILE_CAST( int *, malloc(sizeof(*ptrC)) ); |
Partager