This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F280039C:如何将自定义错误添加到编译器解析器中

Guru**** 2943370 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1353156/tms320f280039c-how-to-add-custom-errors-to-the-compiler-parser

器件型号:TMS320F280039C

尊敬的专家:

我的客户想要向编译器解析器中添加定制错误、例如、我们已经遇到了:

  • #66期待一个";"

但是如何添加

  • #999我定义的错误

是否可以这样做?

谢谢。

挂起

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    使用 C11功能进行称为静态断言的编译时间检查。  例如...

    #include <assert.h>
    
    void fxn(void)
    {
        static_assert(sizeof(char) < sizeof(int), "char is NOT smaller than int!");
    }

    由于默认情况下不启用 C11支持、因此请使用编译器选项 ——C11

    谢谢。此致、

    -乔治