Marco error of CW10.6

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

Marco error of CW10.6

1,607件の閲覧回数
kehanqin-b46569
NXP Employee
NXP Employee

Hi,experts

I am helping customer to create a calendar , the code I once used on K60, now I migrate it to PT60,platform is not problem but point is as long as I used marco to define count and use in algorithm, the value go crazy...

It maybe some setting of CW10.6  cause it.

Please see the picture below:

use the lower part, work fine, use upper, once the time go around 3 hours 40 minutes, the year will add 1 directly.

17844_17844.pngcalendar issue.png

and a other problem, I cannot multiply "one" element of a structure directly, once used, value go crazy again...

I must give it to a variable first, then works fine.

even so, still cannot use marco instead of 3600, will reach a wrong value.

17845_17845.pngcalendar issue 1.png

17849_17849.pngcalendar issue_1.png

 

My code attached, thanks!

Original Attachment has been moved to: GREE-COOKER-TEST-TSI-MTIM-Calendar.zip

ラベル(1)
タグ(2)
0 件の賞賛
返信
2 返答(返信)

1,412件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Kehan,

const define is recognized as int by default. if we want to use it as other type in computation, we need to cast it with exact variable type.

Best Regards,

Zhang Jun

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

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

0 件の賞賛
返信

1,412件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee

Is the issue that sizeof(int) is 2 in your target?

If so, then SEC_OF_DAY overflows in the macro computation.

To make the computation as unsigned long, add a ul suffix to one of the numbers.

E.g.

#define SEC_OF_DAY ( SEC_OF_HOUR * 24uL)

0 件の賞賛
返信