We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, A question regarding C51 v6.23a... The C51 manual suggests that, using the 'large' memory model, sprintf is restricted to a 40 byte parameter list. Having used this knowledge to resolve a bug whose presence is caused by a sprintf call exceeding the 40 byte limit, I was curious as to why the compiler hadn't warned me of this situation. It does seems however, if a sprintf call is made using more than 32 arguments (i.e. irrespective of actual byte count) the compiler does warn of this situation. What gives? Is the restriction byte oriented (as I suspect), in which case why no compiler warning for erroneous sprintf calls, or is it argument count related, as the compiler seems to treat it? Thanks for any illumination. David
Yes, it's very odd that the compiler doesn't emit any kind of diagnostic. It's worse in the small model - 15 bytes I seem to recall. It happens because fixed memory locations are used to pass parameters to scanf, printf and friends. I'm pretty sure this number can be increased but I can't remember how, and 15 seconds of looking at the manual hasn't helped. Stefan
I remember hitting a similar problem with a function that had variable argument list - one that I had written myself in this case. I overran the limit without getting any warning from the compiler.