"Undefined macro or opcode: extern"

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

"Undefined macro or opcode: extern"

ソリューションへジャンプ
1,305件の閲覧回数
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 件の賞賛
返信
1 解決策
745件の閲覧回数
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 件の賞賛
返信
1 返信
746件の閲覧回数
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 件の賞賛
返信