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

How to use the static variables in other files? like use m_hrs_c in files other than main.c

It's a coding question. Maybe it has nothing to do with NRF.

I'm playing the central example hrs. I have a custom .c file that wants to access the m_hrs_c variable defined in main.c.

Because m_hrs_c  is defined as a static variable, I cannot access it in my c file.

I tried to define m_hrs_c  as a GLOBAL variable(like  ble_hrs_c_t m_hrs_c2;), yes it is accessible now.

But some places this GLOBAL  doesn't work. I think some data are not filled correctly, as it is a complicated structure.

What's the right way to use this static variable in other files?Thanks.

Related