undefined reverence problem.

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

undefined reverence problem.

853 Views
jacewalton
Contributor III

in PE_Types.h there is a macro

#define PE_LDD_COMPONENT_FLASH_ID                0x0DU

I reverence that macro in FLASH.c 

in FLASH.c there is a #include for FLASH.h (which has #include PE_Types.h) as well as PE_Types.h in it. however I am getting build errors in my code that states 

'PE_LDD_COMPONENT_FLASH_ID' undeclared (first use in this function) FLASH.c /wt+FX/Generated_Code line 282 C/C++ Problem

basicaly I use #include PE_Types.h twice and it still does not recognize the macro. if I redeclair the macro in FLASH.c it builds fine but why is PE_Types not recognized? 

I have not had this problem before. what is causing this?

0 Kudos
Reply
3 Replies

691 Views
bobpaddock
Senior Contributor III

Collisions in header guards for multiple inclusions can cause these kind of things.

x.h contains:

#ifndef X
#define X (1)

/* stuff */

#endif

Yet some previous thing defined X so that subsequent header file is never processed.

To track down these kind of problems add

#error __FILE__ __LINE__

inside #if s to see where the code actually gets.
#error will stop the compiler at that point.

Remove that one and see if gets to the next one that you think it should.

Also is the error message 'undeclared' or 'undefined' these are two different things?

'undefined' would indicate a problem with the macro definition.

 'undeclared indicates a problem with its usage.
 Does the variable actually exist?  Is it misspelled in some subtle way?

0 Kudos
Reply

691 Views
jacewalton
Contributor III

I do have the block

#ifndef X
#define X (1)

 

 

/* stuff */

 

#endif

in my code

it does exits and is not misspelled. 

Even when I only have to one #include file.h I still get the same error

0 Kudos
Reply

691 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello    Jace,

I think after you add the definition to the file of "PE_Types.h",

 #define PE_LDD_COMPONENT_FLASH_ID                0x0DU‍

you click the "generate code " button ,then the definition disappeared . Please check it .

Hope it helps


Have a great day,
TIC

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

0 Kudos
Reply