sto ottenendo questo avvertimentoC++ troncamento del valore costante
warning C4309: 'initializing' : truncation of constant value
e quando provo ad eseguire il mio dll si invia solo 4 byte invece dei 10 byte.
Cosa potrebbe esserci di sbagliato?
Ecco il mio codice:
int WINAPI MySend(SOCKET s, const char* buf, int len, int flags)
{
cout << "[SEND:" << len << "] ";
for (int i = 0; i < len; i++) {
printf("%02x ", static_cast<unsigned char>(buf[i]));
}
printf("\n");
//causing the warning:
char storagepkt[] = {0x0A, 0x00, 0x01, 0x40, 0x79, 0xEA, 0x60, 0x1D, 0x6B, 0x3E};
buf = storagepkt;
len = sizeof(storagepkt);
return pSend(s, buf, len, flags);
}
UPDATE
int (WINAPI *pSend)(SOCKET s, const char* buf, int len, int flags) = send;
int WINAPI MySend(SOCKET s, const char* buf, int len, int flags);
UPDATE
Come suggerito ho provato memcpy:
memcpy((char*) buf, storagepkt, sizeof(storagepkt));
UPDATE
unsigned char storagepkt[] = {0x0A, 0x00, 0x01, 0x40, 0x79, 0xEA, 0x60, 0x1D, 0x6B, 0x3E};
riparato.
Il codice chiama 'pSend()', ma non viene presentato. Invece è 'MySend()'. C'è un errore di battitura o qualcosa che manca? – wallyk
Sto usando le deviazioni. entrambi sono dichiarati :) – madziikoy
@wallyk 'pSend' viene chiamato da dentro 'MySend' –