Estoy experimentando con XCode e intentando compilar el código de Windows de otra persona.¿Por qué me sale "Uso del identificador no declarado 'malloc'"?
Hay esta:
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;
}
Se trata de un archivo de cabecera.
Me llama a cabo en
El uso de identificador no declarado 'malloc'
Y también para strlen, memcpy y libre.
¿Qué está pasando? Lo siento si esto es dolorosamente simple, soy nuevo en C y C++
¿Está usted incluyendo stdlib.h? –
@WillAyd Acabo de incluirlo, y los errores se redujeron a solo strlen y memcpy ahora. Gracias, pero ¿qué hay de estos 2? –