Struct define in PE

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

Struct define in PE

跳至解决方案
597 次查看
danielchai
Senior Contributor I

Hi,

I used PEs generate a test project. Then I define a structure in ProcessorExpert.c

typedef struct {

    int a;

    int b;

}Test;

 

Then in main, I use " Test test_data;" to define it, but when I compile it, it shows:

"

Test  test_data; 

>expression syntax error

"

Any ideas about this?

 

Thanks.

 

-Daniel

标签 (1)
0 项奖励
1 解答
502 次查看
TICS_Fiona
NXP Employee
NXP Employee

According to ANSI rule, the variable defination should be placed at the beginning in the function, and before program code.

在原帖中查看解决方案

0 项奖励
2 回复数
502 次查看
danielchai
Senior Contributor I

I found some weird things in ProcesssorExpert.c .

When I put the "Test test_data" before calling the function " PE_low_level_init(); ", it compile the project correctly.

But when I put " Test test-data" after calling the function "PE_low_level_init();", it complains the syntax error.

503 次查看
TICS_Fiona
NXP Employee
NXP Employee

According to ANSI rule, the variable defination should be placed at the beginning in the function, and before program code.

0 项奖励