[riot-users] Global Variable Usage

Matthew Blue matthew.blue.neuro at gmail.com
Sat Nov 3 08:06:38 CET 2018

Hi Navneet,

As far as I am aware the only decent way to do this in C is to only
reference a global variable using "extern" in your header file, and
then define it in a different file that is only built once (often a .c
file). See for instance, "saul_reg" in "sys/include/saul_reg.h" and

Matthew Blue

On Sat, 3 Nov 2018 06:14:52 +0000
Navneet Pandey <navneet.pandey at outlook.in> wrote:

> Hello,
> I am wondering how does RIOT handles the use of global variables
> across multiple files. I need access an array across multiple system
> files (RIOT/sys/net/gnrc/). If I include the custom header file, I
> get "multiple definition error". May I request for a solution to this
> kind of issue.
> I tried looking up how RIOT was internally accessing such a variable.
> I was unable to find it. Please point out any such usage, if possible.
> Additional details can be found at
> https://github.com/RIOT-OS/RIOT/issues/10186 (please look at the last
> comment by me(npcode15)). I am asking this question here as it might
> not be relevant for that issue.
> Thank you.
> Regards,
> Navneet Pandey

More information about the users mailing list