2020-11-27 09:32 AM
Hello, I'm having troubles with a library in C
I've made a library named "LedControl" divided in "LedControl.h" and "LedControl.c"
So far the header file is like this:
#ifndef SRC_CUST_LEDCONTROL_H_
#define SRC_CUST_LEDCONTROL_H_
#define LC_POINTER_LIST_LEN 255
// VAL1 VAL2 END ON/OFF TR1 TR0 PWMv FLOAT 32 CHANGE
uint8_t WORD_IT[] = {0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t WORD_IS[] = {0x03, 0x04, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t WORD_TWENTY_MINUTES[] = {0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t WORD_TWENTYFIVE_MINUTES[] = {0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t WORD_FIVE_MINUTES[] = {0x14, 0x15, 0x16, 0x17, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
//[... more array definitions]
void LC_transitionIn(uint8_t *chars, uint16_t time);
void LC_transitionOut(uint8_t *chars, uint16_t time);
void LC_Control_tick();
#endif /* SRC_CUST_LEDCONTROL_H_ */
And the source file is just:
#include "LedControl.h"
void LC_Control_tick()
{
}
Problem is, when I try yo compile I get an error for each variable declaration in the header file like this:
../Core/Src/cust/LedControl.h:129:22: error: unknown type name 'uint8_t'
I figured "ok, I just add #incldue <stdint.h> in my source file like this:
#include <stdint.h>
#include "LedControl.h"
void LC_Control_tick()
{
}
And then I get a whole bunch of error like this (one per variable declaration)
Core/Src/main.o:C:/CubeProj/RelojN/Debug/../Core/Src/cust/LedControl.h:125: multiple definition of `WORD_WKD_SU'
Core/Src/cust/LedControl.o:C:/CubeProj/RelojN/Debug/../Core/Src/cust/LedControl.h:125: first defined here
The header file LedControl.h is only being included once in my main file, and it has a #Ifdef right in the header!
I have to add that I allready have other source and header files in the same project included in the exact same way that also use uint8_t and they work just fine
Thank you!
Solved! Go to Solution.
2020-11-27 09:47 AM
You should read a basic book on C first. Variable definition in header files is nonsense.
2020-11-27 09:47 AM
You should read a basic book on C first. Variable definition in header files is nonsense.
2020-11-27 09:55 AM
Got it! thanks!