| ??? 05/10/02 08:33 Read: times |
#22798 - RE: More details on memory errors |
unsigned long num1 = 500; char numstr1[5]; sprintf(numstr1, "Num 1 is %lu", num1); se_print( numstr1 );where the se_print() function expects a variable of type (const rom char *). This returns an error of "argument #2: memory spaces do not match", referring to the use of sprintf(). I don't know your compiler, but I guess that "rom char *" means "pointer to a character stored in the CODE memory space" But your definition of 'numstr1' does not place it in CODE memory space (presumably it's in your current default space). So the error message is correct, and says literally what it means: "memory spaces do not match" This is a commpiler-specific issue. "I looked again at the prototype for sprintf() and noticed that it expects a (const char *), so I declared const char *lu_str = "%lu"; and replaced the second argument of sprintf() with lu_str." This is standard ANSI 'C': The 'const' in the prototype simply tells the compiler that the implementation of sprintf() must not modify the actual parameter. It has no effect on your actual parameters! "Now the error I get is "operands of '=' are not pointing to the same memory space" in reference to the declaration of lu_str." It's those memory spaces again - see above! I mentioned this before: http://www.8052.com/forum/read.phtml?id=22496&top= Do you understand the different memory spaces - CODE, DATA, IDATA, PDATA, XDATA - in the 8051 archicture? If not, you need to download & read the three 80C51_FAM_*.pdf documents from: http://www.semiconductors.philips.com/products/...other.html Your compiler manual should also have something to say on the matter |



