我是靠谱客的博主 体贴鞋垫,这篇文章主要介绍C语言预处理指令#error,现在分享给大家,希望可以做个参考。

  在FreeRTOS的FreeRTOS.h文件中看到一句代码

#ifndef configMINIMAL_STACK_SIZE
    #error Missing definition:  configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h.  configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task.  Refer to the demo project provided for your port for a suitable value.
#endif

然后我把FreeRTOSConfig.h中的宏configMINIMAL_STACK_SIZE注释掉,然后编译,报错如下:

..FreeRTOSincFreeRTOS.h(82): error:  #35: #error directive: Missing definition:  configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h.  configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task.  Refer to the demo project provided for your port for a suitable value.

可以看到,#error在这里用来判断是否定义了某个宏,如果没有定义就产生一个编译错误,有利于后期排错。除此之外,也可以用来判断某个宏的值是否符合要求。

最后

以上就是体贴鞋垫最近收集整理的关于C语言预处理指令#error的全部内容,更多相关C语言预处理指令#error内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(139)

评论列表共有 0 条评论

立即
投稿
返回
顶部