strlen

I am using Freertos on a Intel Galileo Gen 2 board and I am trying to copy and compare some strings but i am having some trouble. As I see I have available on the libraries distribbuted the strlen, strcpy, memcpy and memcmp. What I am seeing is that both strlen and strcpy don’t work. They are even commented as “Extremely crude implementations” in the code. In fact, strlen seems not be be even implemented. memcpy and memcmp seem to do the job, but they ask for the memory string size to work with. As I am not able to use strlen, I have been defining a maximun string size to perform this operations. I understand that this is not optimal, but at least it works for copying. My problem is that if I compare two strings, one static value and the other as an entry to a function I get values that don’t fit what I was expecting. ~~~

define VARSIZE 50

static char reference[VARSIZE]; int locate(char id[] ) { … r = memcmp(conTab[a].reference,id,VARSIZE); … } ~~~ When I set both values to “refe03” (so comparison result should be 0) I get as a result value 43. If I set other values (f.e. “refe04” for id) I get 45 as a result. Am I doing something wrong? How can I solve this? Thanks,

strlen

It might be that GCC is using a builtin version of the function. Try adding -fno-builtin-strlen to the command line to see if that fixes the strlen() problem. Also, the source code for the function is there and is very short, so you can step through it easily enough to see what it is doing to check it is correct. The crude implementations of the functions are only provided because the demo as downloaded makes no assumptions as to the C libraries that are available with the compiler. Ideally link to a suitable GCC unhosted C library, then use the functions provided by the C library.

strlen

Running the gcc command with -fno-builtin-strlen changes nothing in the response. I get this error: undefined reference to 'strlen' I have tried to remove the string.h and freestanding_functions.c files to force it to use the standard libraries but it looks like it is not able to find them. I have included the cygwin libraries I have in my computer (by adding C:cygwin64usrinclude to the eclipse include folders) but it does not use them. Where can I get a valid library set to use? Thanks, Jordi

strlen

For anyone wondering, I have succesfully used this simple method for implementing strlen: sizet strlen(const char *s) { sizet i; for (i = 0; s[i] != ‘’; i++) ; return i; } It can be incorporated to the freestanding_functions.c file and it works perfectly.