C niewbie question

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
eribla
Posts: 20
Joined: Fri Nov 29, 2013 1:10 am

C niewbie question

Post by eribla »

Hi guys

I realize that you can't teach me "C" here. I have programmed other languages including C#, but the whole include file business is still somewhat mysterious to me, especially when it does not work.

Here is my issue:
My main program stripped:

Code: Select all

#include "ch.h"
#include "hal.h"
#include "test.h"
#include "lcd.h"

main()
{
LCDinit();
}



The include file:

Code: Select all

#ifndef _LCD_H_
#define _LCD_H_

#ifdef __cplusplus
extern "C" {
#endif
void LCDClear(void);
void LCDInit(void);
void LCDPrintRow(uint8_t,uint8_t []);
#ifdef __cplusplus
}
#endif

#endif /* _LCD_H_ */



And of course there is a a LCD.c file, where LCDInit is defined:

Code: Select all

LCDInit(){
dostuff;
}





Whatever I do, and I have played with this for days now, I come back to get:

..\main.c(243): warning: #223-D: function "LCDInit" declared implicitly.

Why is this so? LCD.h is there and can be found.
And when do I have to use the " #ifdef __cplusplus" clause? ( I just stole it from a different file)

Question 2:

in this code I found for the LCD driver, some of the functions were declared "inline" which is a compiler directive that should not make a difference.

I have not managed to compile any inline function without getting "this declaration has no storage or type specifier.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: C niewbie question

Post by Giovanni »

Hi,

Note LCDInit() :)

Note that you must not return from the main() function too.

"static inline" functions are functions that have no their own existence, can only be inlined, usually are defined in header files, it is a C99 construct.

Giovanni
efuentes
Posts: 35
Joined: Wed Jul 25, 2012 6:16 am

Re: C niewbie question

Post by efuentes »

I've seen this happen if you don't include the source file in your makefile. Try adding LCD.c to your list of sources.
eribla
Posts: 20
Joined: Fri Nov 29, 2013 1:10 am

Re: C niewbie question

Post by eribla »

Thank you for the help.

I removed the #ifdef __cplusplus stuff
and it compiles now...

except for the "inline" issue:

as soon as I define a function as inline I am still getting

LCD\lcd.c(152): warning: #77-D: this declaration has no storage class or type specifier.

By the way I am using Keil, so there is really no make file, but those two "LCD" files are definitely included int the project.


Thanks again
Post Reply