reinterpret_cast compile warnings
To the experts,
I am getting numerous reinterpert_cast warnings, error listed below, and do not understand how to clean them up. Can one of the experts please explain what this is about, how to avoid it, and maybe how to clean it up.
# PROJECT dlpi
# Building Target: getmac
# ENV vars set: COMPFLAGS_LD_getmac=-g0 , COMPFLAGS_C_getmac=-g0 -y
aCC -c -g0 -y -o getmac_address.o getmac_address.c
aCC: current directory is "/build/nitro_project/dlpi"
Warning 749: "getmac_address.c", line 103 # The cast from 'DL_primitives *' to 'dl_ok_ack_t *' is performed as a 'reinterpret_cast'. This operation is non-portable and potentially unsafe.
if( ( ( dl_ok_ack_t * )&dl_prim)->dl_correct_primitive != DL_ATTACH_REQ
^^^^^^^^^^^^^^^^^
... OTHER WARNINGS HERE OF SIMILAR NATURE ....
Linking getmac ...
aCC -g0 -o getmac getmac_address.o
aCC: current directory is "/nfs/hpux-02.reyniers.com/build/nitro_project/dlpi"
done
# PROJECT dlpi BUILD-TARGET Completed
The section of my code that the compiler is complaining about is as follows:
Code:
union DL_primitives dl_prim;
dl_attach_req_t attach_req;
... more code ....
if ( ( ( dl_ok_ack_t * )&dl_prim)->dl_correct_primitive != DL_ATTACH_REQ ) {
errno = EPROTO;
return(-1);
}
The structure(s) being referenced are from sys/dlpi.h. I have provided code snips of these structures as defined in sys/dlpi.h.
From dlpi.h Include:
Code:
/*
* DL_OK_ACK, M_PCPROTO type
*/
typedef struct {
uint32_t dl_primitive; /* DL_OK_ACK */
uint32_t dl_correct_primitive; /* primitive being acknowledged */
} dl_ok_ack_t;
union DL_primitives {
uint32_t dl_primitive;
dl_info_req_t info_req;
dl_info_ack_t info_ack;
dl_attach_req_t attach_req;
dl_detach_req_t detach_req;
dl_bind_req_t bind_req;
dl_bind_ack_t bind_ack;
dl_unbind_req_t unbind_req;
dl_subs_bind_req_t subs_bind_req;
dl_subs_bind_ack_t subs_bind_ack;
dl_subs_unbind_req_t subs_unbind_req;
dl_ok_ack_t ok_ack;
dl_error_ack_t error_ack;
dl_connect_req_t connect_req;
dl_connect_ind_t connect_ind;
dl_connect_res_t connect_res;
dl_connect_con_t connect_con;
dl_token_req_t token_req;
dl_token_ack_t token_ack;
dl_disconnect_req_t disconnect_req;
dl_disconnect_ind_t disconnect_ind;
dl_reset_req_t reset_req;
dl_reset_ind_t reset_ind;
dl_reset_res_t reset_res;
dl_reset_con_t reset_con;
dl_unitdata_req_t unitdata_req;
dl_unitdata_ind_t unitdata_ind;
dl_uderror_ind_t uderror_ind;
dl_udqos_req_t udqos_req;
dl_enabmulti_req_t enabmulti_req;
dl_disabmulti_req_t disabmulti_req;
dl_promiscon_req_t promiscon_req;
dl_promiscoff_req_t promiscoff_req;
dl_phys_addr_req_t physaddr_req;
dl_phys_addr_ack_t physaddr_ack;
dl_set_phys_addr_req_t set_physaddr_req;
dl_get_statistics_req_t get_statistics_req;
dl_get_statistics_ack_t get_statistics_ack;
dl_test_req_t test_req;
dl_test_ind_t test_ind;
dl_test_res_t test_res;
dl_test_con_t test_con;
dl_xid_req_t xid_req;
dl_xid_ind_t xid_ind;
dl_xid_res_t xid_res;
dl_xid_con_t xid_con;
dl_data_ack_req_t data_ack_req;
dl_data_ack_ind_t data_ack_ind;
dl_data_ack_status_ind_t data_ack_status_ind;
dl_reply_req_t reply_req;
dl_reply_ind_t reply_ind;
dl_reply_status_ind_t reply_status_ind;
dl_reply_update_req_t reply_update_req;
dl_reply_update_status_ind_t reply_update_status_ind;
};
#define DL_OK_ACK_SIZE sizeof(dl_ok_ack_t)
Thanks In Advance for Any and All Assistance,
DeadPoet