This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

multiple definition of variable in h file

Hi,

Currently im working on creating firmware for out device based on the nrf52832. I have structured my project where i have seperate files for each module i am creating (c and h file). The C-files are added to the project and the .h files are in a folder that is linked in the project. Declaring a public funtion for example is not a problem and everything seems to work fine.

The problem arises when i declare a variable in a .h file. i will get an error saying:

Output/serial_pca10040 Release/Obj/LIS3DH.o:(.bss.GravStat+0x0): multiple definition of `GravStat'

the .h file is surrounded by:

#ifndef __LIS3DH__
#define __LIS3DH__

and

#endif    // __LIS3DH__

to ensure it isnt included anywhere twice.

The value i declared is unique and it is definetly the first time it is declared. also changing the value name to something obscure results in the same error.

regards,

Tim

Related