static volatile

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

static volatile

1,905 次查看
neilporven
Senior Contributor I

Hi everyone,

I am converting some code that was done for a TI MSP430 to a Kinetis part.  When

I compile the code, it is complaining about this variable, saying that it is unknown type name.

static volatile tTRF797x_Status  g_sTrfStatus;

Is this declared incorrectly?  

Is there a document that explains all the legal types in the Kinetis IDE?

Thank you,

Neil

0 项奖励
回复
5 回复数

1,525 次查看
bobpaddock
Senior Contributor III

Some of the TI compilers are not the best.

The first one simply ignored 'volatile', which shows how bad they were.

The people writing it were compiler writers with no embedded experience.

A typedef defines no space, there is no reason for an extern after it.

0 项奖励
回复

1,525 次查看
BlackNight
NXP Employee
NXP Employee

Hi Neil,

I think the reason is that the compiler does not see the declaration of tTRF797x_Status. Make sure it is declared before usinig it, probably you missed to include the header file for it?

I hope this helps,

Erich

0 项奖励
回复

1,525 次查看
neilporven
Senior Contributor I

Hi Erich,

After going back and forward with support from TI, they said that tTRF797x_Status was declared in say

File2.h like so:

typedef enum
{
    TRF_IDLE,
    TX_COMPLETE,
    RX_COMPLETE,
    TX_ERROR,
    RX_WAIT,
    RX_WAIT_EXTENSION,
    TX_WAIT,
    PROTOCOL_ERROR,
    COLLISION_ERROR,
    NO_RESPONSE_RECEIVED,
    NO_RESPONSE_RECEIVED_15693
}tTrfStatus;
What was strange is that I expect to see this line somewhere in this .h file
extern  tTRF797x_Status tTrfStatus;   <----- which is not there?
also I expected to see this in the File2.c
tTRF797x_Status tTrfStatus;  <----- which is not there?
and finally in File1.h the following:
#include "File2.h" <---- This is present
so that you can the make the following declaration in File1.c
static volatile tTRF797x_Status  g_sTrfStatus;   <------ This is what the compiler is having an issue with
Am I missing anything here?
Thanks,
Neil
0 项奖励
回复

1,525 次查看
BlackNight
NXP Employee
NXP Employee

Hi Neil,

you write:

>>extern  tTRF797x_Status tTrfStatus;   <----- which is not there?

which does not make any sense. I rater would expect

extern tTrfStatus tTRF797x_Status;

and instead of

>>tTRF797x_Status tTrfStatus;  <----- which is not there?

it should be

tTrfStatus tTRF797x_Status;

According the information you have provided, the tTrfStatus is an enumeration type.

Therefore your

>>static volatile tTRF797x_Status  g_sTrfStatus;

should be writen as

static volatile g_sTrfStatus tTRF797x_Status;

I don't know how good you are at C programming or if this is just an oversight on your side, but in C you have to specify first the type and then the variable name, e.g. as in

static volatile int myVariable;

I hope this helps,

Erich

0 项奖励
回复

1,525 次查看
neilporven
Senior Contributor I

Hi Erich,

I am trying to understand code that was done by a software engineer from TI. 

Yes, the static volatile tTRF797x_Status g_sTrfStatus is an oversight by me, I should have picked

up on this.  I will change it, but I don't understand how this could be compiling on there side.  I imagine

TI's compiler should had recognize the above as error and they should have run into this issue.

Thanks,

Neil

0 项奖励
回复