I will admit that I am probably doing something wrong, but as you can see in the enclosed file I'm setting a string value to struct member, and then returning that from a function. When I check to see if the string value is the same, as I set in the function, I get some weird results.
Here is the output from the compile and execution with sz80..
sdcc -mz80 function_params.c -o function_params.ihx
function_params.c:26: warning 85: in function putchar unreferenced function argument : 'c'
function_params.c:52: warning 85: in function main unreferenced function argument : 'argc'
function_params.c:52: warning 85: in function main unreferenced function argument : 'argv'
sz80 function_params.ihx
uCsim 0.6-pre54, Copyright (C) 1997 Daniel Drotos.
uCsim comes with ABSOLUTELY NO WARRANTY; for details type show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; typeshow c' for details.
0> Loading from function_params.ihx
4990 words read from function_params.ihx
run
Simulation started, PC=0x000000
'7'
after memcpy
'7'
after memcpy
'test123' ==? 'te��'
'456test' ==? '456test'
Assert(strcmp(o1->string.val, "test123")==0) failed in function main at line 49 in file function_params.c.
my version of sdcc is (3.9.0):
sdcc --version
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ez80_z80/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk14/pdk15 3.9.0 #11195 (Linux)
published under GNU General Public License (GPL)
Any ideas?
Billy
fyi.. I found an error (sizeof(my_string_) should be sizeof(my_obj) in the my_string_fun (first line), but when I run it with the corrections, I still get the same error... Any ideas?
The line
allocates space for just a single char. You probably meant to allocate strlen(v) + 1 chars instead.
Philipp