How can I fix multi #if #elif error

3 次查看(过去 30 天)
I ran polyspace bug finder 2015a in 32bit win7.
I have some errors.
I added Preprocessor Macros SAM and SAM=1, SAM=TRUE, SAM=true
But polyspace report error : Error: #error directive: Unsupported device.
#if XMEGA || MEGA || TINY
#include "interrupt/interrupt_avr8.h"
#elif UC3
# include "interrupt/interrupt_avr32.h"
#elif SAM
# include "interrupt/interrupt_sam_nvic.h"
#else
# error Unsupported device.
#endif

回答(1 个)

Alexandre De Barros
Hello,
Defining the macro SAM is enough to make the preprocessor process the #elif SAM directive. Actually defining SAM to true or TRUE will override the simple macro definition.
Hence, the two last macros will lead to a compilation error because the #elif SAM statement will become #elif TRUE or #elif true, and true or TRUE are not Ansi-C keywords.
The solution is then to keep only the macro SAM and delete the 3 other ones.
Best regards,
Alexandre
  2 个评论
jaeseok lee
jaeseok lee 2016-11-3
Hello Alexandre
I am sorry but I already do it.
It is not working.
First time I just add SAM. It is not working.
Second time, add SAM=1, It is not working
Alexandre De Barros
Hello,
this is strange because I tested your sample code with the simple macro SAM defined, and Polyspace was able to process the line #include "interrupt/interrupt_sam_nvic.h".
Then it fails because in my environment Polyspace was not able to find the file "interrupt/interrupt_sam_nvic.h" but this shows that the macro SAM was recognised by the Polyspace preprocessor.
I suggest you to contact the support and attach the verification log, they will be able to see what is going wrong.
Regards,
Alex

请先登录,再进行评论。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by