Page 1 of 1

C niewbie question

Posted: Sun Dec 15, 2013 8:30 pm
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.

Re: C niewbie question

Posted: Sun Dec 15, 2013 8:34 pm
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

Re: C niewbie question

Posted: Sun Dec 15, 2013 8:42 pm
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.

Re: C niewbie question

Posted: Mon Dec 16, 2013 2:34 am
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