Disable automatic external object creation by linker

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

Disable automatic external object creation by linker

跳至解决方案
813 次查看
rvumbaca
Contributor I

Hi,

 

I am using CW for MCU 10.6 with HCS08.

 

If I define an extern variable but it is not actually declared anywhere (or if I set it to 'static' and try to access it from a different module using an 'extern' declaration) the linker will generate the warning L1823 and will automatically create the object locally.

 

I do not want this behaviour, instead I want a linker error to be generated as expected.

 

Is it possible to disable this 'feature' in the linker? I have looked through the options and searched through these forums, but have found no solution.

 

Thanks,

 

Rosario

标签 (1)
0 项奖励
1 解答
624 次查看
BlackNight
NXP Employee
NXP Employee

Hi Rosario,

you can map that warning message to an error with the following linker option:

-WmsgSe1823

That way it does not create such an automatic object.

I hipe this helps,

Erich

在原帖中查看解决方案

0 项奖励
4 回复数
624 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

hi Rosario,

there are two methods to disable warnings:

(1).  add option-WmsgSd<number>  to Linker setting.<number>: Message number to be disabled, e.g., 1801

Example     -WmsgSd1823

(2). use #pragma OPTION ADD "-WmsgSd1823"
   in C code. for more information about #pragma OPTION  usage, please see CW help manual.

Hope this helps!

Best Regards,
Zhang Jun

=========================================

this answer is for you. if it helps, please click on "Correct Answer" button. Thanks!


0 项奖励
624 次查看
rvumbaca
Contributor I

Hi Jennie,

That pragma cannot be used to supress messages, to do that you use #pragma MESSAGE DISABLE

But I *Do Not* want to hide the message, I want to *Stop Automatic Object Creation*. I have looked through the manuals and it seems that this is not possible.

Regards,

Rosario

0 项奖励
625 次查看
BlackNight
NXP Employee
NXP Employee

Hi Rosario,

you can map that warning message to an error with the following linker option:

-WmsgSe1823

That way it does not create such an automatic object.

I hipe this helps,

Erich

0 项奖励
624 次查看
rvumbaca
Contributor I

Hi Erich,

Thanks! That solved the problem.

Regards,


Rosario

0 项奖励