I have a problem with sprintf, using the GNU gcc compiler for 68k series processor.
I am trying to create a buffer of data, adding strings and variables to that buffer.
Look at the code (the buffer is unsigned char, 5120 bytes long).
int AddDataFunc1(unsigned char * ptrDataBuf)
NewDataLen += sprintf((char*)(ptrDataBuf+NewDataLen),"%s %s %s,",String1,String2,String3);
NewDataLen += sprintf((char*)(ptrDataBuf+NewDataLen),"%1d,%1d,",Variable1,Variable2);
I am calling this function like this:
NumBytesAdded += AddDataFunc1(&DataBuffer[NumBytesAdded]);
NumBytesAdded += AddDataFunc2(&DataBuffer[NumBytesAdded]);
and so on...
The problem is that sprintf ALWAYS returns a negative number (indicating it's failing somewhere) - but it works fine under MSVC, not the GNU compiler. I've tried looking everywhere on websites etc for help and can find nothing.
There is plenty of memory so it's not that, I am sure. I am running GCC libraries egcs-2.91.66
If anyone can help I will be eternally grateful.