Global variable declaration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Global variable declaration

Jump to solution
667 Views
shauldorf
Contributor V

I’m new to KDS/KSDK, Where I define global variable that will be seen by main.c , event.c  and maybe in future by other files in the project?

Labels (1)
1 Solution
426 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello shaul dorf:

That is more a C programming question than a question related to KDS or KSDK. If a global variable is to be seen by several source files, you have to define it in one of your .c source files and declare it as extern in a header file. Then include such header file from any source file that needs to "see" the global variable.

If I misunderstood your question please let me know.

Regards!

Jorge Gonzalez

View solution in original post

0 Kudos
2 Replies
426 Views
shauldorf
Contributor V

Jorge Thanks;

I already did it and it is working. I’m hardware oriented, I
have seen that PE generates many files so I thought that it can be done automatically
based on information in main.c file

But in second thinking it is a nonsense because only the programmers
knows in which file this extern definition has to be placed.

Any way thanks for your help to finally understand it.

Shaul

427 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello shaul dorf:

That is more a C programming question than a question related to KDS or KSDK. If a global variable is to be seen by several source files, you have to define it in one of your .c source files and declare it as extern in a header file. Then include such header file from any source file that needs to "see" the global variable.

If I misunderstood your question please let me know.

Regards!

Jorge Gonzalez

0 Kudos