Page 1 of 1

strcmp

Posted: Sat Aug 16, 2014 9:49 am
by fastlink30
i'm new on chibios (2.6.5) and chibistudio (preview 6) on STM32F4 discovery board

Code: Select all

void cmd_oven(BaseSequentialStream *chp, int argc, char *argv[]) {
  int value = 0;
  COMANDI_ERROR err = NEED_PARAMETERS;

  (void)argv;

  if (argc > 0) {
    if (strcmp(argv[0], "?") == 0) { <-------
......


when i debug, and debugger arrive to strcmp line, argc value become 0 and argv is resetted (before arrive to strcmp argc=1 and argv point to string).
i must include something in makefile to use this function or there are bug with this function? is problem with heap?
the #include <stdio.h>/<string.h>/<stdlib.h> at the top of the main there are.

thanks

Re: strcmp

Posted: Sat Aug 16, 2014 9:58 am
by Giovanni
Hi,

Probably you are debugging with optimizations enabled, try compiling using -O0. Optimizations make variables disappear when no more needed and generally make the debug experience messy.

Giovanni

Re: strcmp

Posted: Sat Aug 16, 2014 11:16 am
by fastlink30
yes, i have disabled optimization and now is going well.

thanks! ciao