"Undefined macro or opcode: extern"

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

"Undefined macro or opcode: extern"

Jump to solution
1,304 Views
gomer
Contributor I

Hey all.  I have a problem that is driving me nuts.  I'm building MQX 3.6 on a CF52256 using CW 10.

 

My problem is this:  I want to get access to a couple of Linker-defined variables in my 'user_config.h' so I can redefine the FlashX available size in terms of those values.  Below is the simple code I'm trying to add:

 

 

extern unsigned char __FLASHX_START_ADDR[]; // defined in .lcf file
extern unsigned char __FLASHX_END_ADDR[];   // defined in .lcf file

#define FLASHX_START_ADDR ((uint_32)__FLASHX_START_ADDR)
#define FLASHX_END_ADDR   ((uint_32)__FLASHX_END_ADDR)


// this is the end result I'm trying to achieve
#define BSPCFG_FLASHX_SIZE      ( FLASHX_END_ADDR - FLASHX_START_ADDR )

 

The problem I'm having is after the PSP project has compiled the code, the Assembler pukes on those two lines at the top... the 'extern' declarations, with the following error:

 

Undefined macro or opcode: extern

 

That makes no sense to me whatsoever, since the BSP project will compile and assemble just fine, and it certainly uses this 'user_config.h' file all over the place.  I've compared the Assembler settings between the two projects (BSP and PSP) and find no differences.

 

Anybody know what is going on?  Please help!

 

Thanks,

Gomer

0 Kudos
Reply
1 Solution
744 Views
DavidS
NXP Employee
NXP Employee

Hi Gomer,

Here is my simple example of getting a variable from the linker script into a FSLMQX application.

 

In linker script I added:

    ___DECAF = 0xBAD;

 

In FSLMQX application "C" file I added the following at top:

  extern uchar __DECAF[];

  #define LINKER_DB ((uint_32)__DECAF)

 

added printf down in the code:

   printf("Linker File ___DECAF = 0x%08x\n", LINKER_DB);

 

 

If you recompile the FSLMQX application the output on terminal should be:

Linker File ___DECAF = 0x00000bad

 

Please note the linker script declaration has three underscore for DECAF and two in the "C" file.

 

Looking at your code it appears as though it should work but my only concern is the BSP_FLASHX_SIZE name is used elsewhere in FSLMQX so maybe you should try a different name.

When I tried your code I got a redfined error but when I renamed it all worked fine.

Regards,

David

View solution in original post

0 Kudos
Reply
1 Reply
745 Views
DavidS
NXP Employee
NXP Employee

Hi Gomer,

Here is my simple example of getting a variable from the linker script into a FSLMQX application.

 

In linker script I added:

    ___DECAF = 0xBAD;

 

In FSLMQX application "C" file I added the following at top:

  extern uchar __DECAF[];

  #define LINKER_DB ((uint_32)__DECAF)

 

added printf down in the code:

   printf("Linker File ___DECAF = 0x%08x\n", LINKER_DB);

 

 

If you recompile the FSLMQX application the output on terminal should be:

Linker File ___DECAF = 0x00000bad

 

Please note the linker script declaration has three underscore for DECAF and two in the "C" file.

 

Looking at your code it appears as though it should work but my only concern is the BSP_FLASHX_SIZE name is used elsewhere in FSLMQX so maybe you should try a different name.

When I tried your code I got a redfined error but when I renamed it all worked fine.

Regards,

David

0 Kudos
Reply