Eksperymentuję z XCode i próbuję skompilować czyjś kod Windows.Dlaczego otrzymuję komunikat "Używanie niezadeklarowanego identyfikatora" malloc ""?
Jest to:
inline GMVariable(const char* a) {
unsigned int len = strlen(a);
char *data = (char*)(malloc(len+13));
if(data==NULL) {
}
// Apparently the first two bytes are the code page (0xfde9 = UTF8)
// and the next two bytes are the number of bytes per character (1).
// But it also works if you just set it to 0, apparently.
// This is little-endian, so the two first bytes actually go last.
*(unsigned int*)(data) = 0x0001fde9;
// This is the reference count. I just set it to a high value
// so GM doesn't try to free the memory.
*(unsigned int*)(data+4) = 1000;
// Finally, the length of the string.
*(unsigned int*)(data+8) = len;
memcpy(data+12, a, len+1);
type = 1;
real = 0.0;
string = data+12;
padding = 0;
}
Jest to w pliku nagłówka.
on nazywa mnie na
Zastosowanie nierejestrowanej identyfikatorze 'malloc'
A także dla strlen, memcpy i za darmo.
Co się dzieje? Przepraszam, jeśli to jest boleśnie proste, jestem nowy w C i C++
czy włączysz stdlib.h? –
@WillAyd Właśnie dodałem to, a błędy zostały skrócone do teraz tylko strlen i memcpy teraz. Dzięki, ale co z tymi 2? –