I'm having a problem with KDS and the pre-processor, I'm not sure if it's me mis-understanding the pre-proxcessor or a bug in the pre-processor
I have the following defines:
#define TIME_ON_POWER 20 // Value is in seconds
#define US_PER_S (US_PER_MS * MS_PER_S)
#define S_TO_US(s) (US_PER_S * s)
They're used in a function such as
uint32_t variable = S_TO_US( 60 - TIME_ON_POWER );
In my mind that should evaluate to 40,000,000 however when I look at it via the debugger it evalutles as 59,999,980
To solve this I just put an extra pair of brackets around 60 - TIME_ON_POWER, this means
uint32_t variable = S_TO_US( (60 - TIME_ON_POWER) );
evaulautes to 40,000,000.
Is this a problem with the KDS pre-processor or is my thinking/understanding flawed?
解決済! 解決策の投稿を見る。
Hi Ben,
Thanks for your reply.
I reproduced this problem on my side.and will report it to developer.
For the moment, please use the workaround you already found.
I will let you know as soon as I get any update from developer.
Thank you for bringing the problem to our attention.
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks
Ben,
You are welcome.
Jennie.
Hi Ben,
How do you define macro US_PER_MS and MS_PER_S?
Can you please upload your demo project here thus we can check it directly?
Besides, please also send me your KDS version.
Thanks.
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Sorry - I missed those defines.
#define US_PER_MS 1000
#define MS_PER_S 1000
Hi Ben,
Thanks for your reply.
I reproduced this problem on my side.and will report it to developer.
For the moment, please use the workaround you already found.
I will let you know as soon as I get any update from developer.
Thank you for bringing the problem to our attention.
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------