Global variable declaration

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Global variable declaration

跳至解决方案
980 次查看
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?

标签 (1)
1 解答
739 次查看
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 项奖励
回复
2 回复数
739 次查看
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

740 次查看
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 项奖励
回复