include string.h

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
antoniolinux
Posts: 38
Joined: Thu Dec 19, 2013 12:59 pm

include string.h

Post by antoniolinux »

Hi to all, i want to do porting of my little project on chibios os, i use a shield SIM900, for use this shield i use AT comand, now when I send a command this shield give me a answer, i want store this answer for controll it.
in my application i use the string type, and all work well.
In chibios i configure the serial comunication, SD3, and all work well but i can't include the string.h library.
i wire

Code: Select all

#include "ch.h"
#include "hal.h"
#include "chprintf.h"
#include <string.h>

but i have this message "unresolve inclusion string.h" i don't know where is the problem, the chprintf work well but the string.h no.
can you help me?
best regards
Antonio
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: include string.h

Post by Giovanni »

Hi,

That is just an Eclipse warning, the program should compile fine.

Giovanni
antoniolinux
Posts: 38
Joined: Thu Dec 19, 2013 12:59 pm

Re: include string.h

Post by antoniolinux »

hi giovanni, i write this easy program

Code: Select all

#include "ch.h"
#include "hal.h"
#include "chprintf.h"
#include  <string.h>

BaseSequentialStream* chp = (BaseSequentialStream*) &SD2;

string s;

int main(void) {
  halInit();
  chSysInit();
  sdStart(&SD2, NULL);
  while (true) {
chprintf(chp, "Hello world\n\r");
    chThdSleepMilliseconds(500);
  }
}


if i don't include the line #include <string.h> and the line string s; all work well, but if use this two line i have this error "main.c:25:1: error: unknown type name 'string'";
i think don't load he library string.h
this is my makefile

Code: Select all

CSRC = $(STARTUPSRC) \
       $(KERNSRC) \
       $(PORTSRC) \
       $(OSALSRC) \
       $(HALSRC) \
       $(PLATFORMSRC) \
       $(BOARDSRC) \
       $(TESTSRC) \
       $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
       $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
       main.c
.....
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
         $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
       $(CHIBIOS)/os/hal/lib/streams \
         $(CHIBIOS)/os/various


it's all correct or i don't see where is the error.

ciao
Antonio
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: include string.h

Post by Giovanni »

A type named "string" is not part of C language as far I know.

Giovanni
antoniolinux
Posts: 38
Joined: Thu Dec 19, 2013 12:59 pm

Re: include string.h

Post by antoniolinux »

you are right, only now i see that in mbed use c++ where it is defined,
thanks
A.
petruchito
Posts: 1
Joined: Wed Jul 12, 2017 4:40 am

Re: include string.h

Post by petruchito »

Just in case someone is annoyed by this warning like me:

Add new entry to Project properties -> Preprocessor include paths -> GNU C -> CDT user setting entries
  • Path C:\ChibiStudio\tools\GNU Tools ARM Embedded\4.9 2015q3\arm-none-eabi\include
  • Check "Treat as built-in"
  • Check "Contains system headers"
Post Reply