Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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


List of 29 messages in thread
TopicAuthorDate
Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings - Niklas            01/01/70 00:00      
ASCII or Binary?            01/01/70 00:00      
RE: ASCII or Binary?            01/01/70 00:00      
RE: ASCII or Binary?            01/01/70 00:00      
RE: ASCII or Binary?            01/01/70 00:00      
RE: ASCII or Binary?            01/01/70 00:00      
RE: ASCII or Binary?            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
Confirmed compatible with Tasking            01/01/70 00:00      
RE: Confirmed compatible with Tasking            01/01/70 00:00      
Typo in above post            01/01/70 00:00      
RE: Confirmed compatible with Tasking            01/01/70 00:00      
RE: Confirmed compatible with Tasking            01/01/70 00:00      
RE: Confirmed compatible with Tasking            01/01/70 00:00      
More details on memory errors            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: More details on memory errors            01/01/70 00:00      
RE: Memory & strings; AT89C51            01/01/70 00:00      
RE: More details on memory errors            01/01/70 00:00      
RE: More details on memory errors            01/01/70 00:00      

Back to Subject List