9S12XEP100 compiler issue: extern a structure

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

9S12XEP100 compiler issue: extern a structure

607 Views
peteyo
Contributor II

Hi,

 

In my CAN application project including 3 files: main.c, CAN_drv.c, and CAN0_app.c.

CAN_drv will contain some CAN driver functions and structures about CAN message.

CAN_app contains some application functions in my system.

main.c will use these application functions in CAN_app.c.

 

CAN_drv.h

typedef struct  {   UINT   id;   BOOL   RTR;    UBYTE  data[8];     UBYTE  prty; } tCAN_MSG; extern tCAN_MSG canRxMsg[5], 

CAN_drv.c

#include "CAN_drv.h" tCAN_MSG canRxMsg[5];

CAN0_app.c

#include "CAN_app.h" void CAN0_RX(tCAN_MSG *msg) { ... }

CAN0_app.h

#include "CAN_drv.h" extern void CAN0_RX(tCAN_MSG *msg);

main.c

#include "CAN_drv.h" #include "CAN_app.h" void main(void){      CAN0_RX(msg); }

 

My CodeWarrior version IDE is 5.9.0 and compile error list occured in CAN0_app.h

"extern void CAN0_RX(tCAN_MSG *msg);"

The error list is below:

C5002: Illegal type,

C1815: msg not declared (or typename),

C1834: Indirection applied to non-pointer,

and other strange error about missing ";" or "}"

 

Is there some declaration i missed?

Or this application structure should be modified to another type?

Labels (1)
0 Kudos
3 Replies

436 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Peter,

What about the define of msg on the main function?

CAN0_RX(msg);  

You'd better send your project , it is convenient for check the problem.

If you can not attached it to here for some privacy , you can create one question on the  salesforce ,

the detail process please refer to this link :

How to submit a new question for NXP Support

Hope it helps

Alice

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

436 Views
peteyo
Contributor II

Hi Alice,

Thanks your reply.

I follow CAN example code from NXP and it contains structure tCAN_MSG and createMessage() in CAN.c/.h

I separate 3 files(CAN_drv, CAN0_app, and CAN1_app) in my project since there are 2 CAN-bus and lots of data of protocol in my application.

Function CAN0_RX() is to check the data from CAN BUS 0 and would be used inside CAN_RXISR() or main().

It seems I need to declare 2 structures (tCAN0_MSG, tCAN1_MSG) and 2 functions(createMessageCAN0, createMessageCAN1) in their own c and header file?

Sincerely,

Peter Yu

0 Kudos

436 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Peter,

Sorry i still recommend your send your project to me ,

then i can refer to the project and your describe to check the problem .

Or only through your describe , you said you have contain the structure tCAN_MSG,

yes , you need declare the structures tCAN0_MSG, tCAN1_MSG if not declared .Also you need include the header files which you need .

Hope it helps

Alice

0 Kudos