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.
工具/软件:Code Composer Studio
您好!
以下代码是从 Tiva C Launchpad 专题讨论会实验14复制的:
#include "stdint.h"
#include "stdbool.h"
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "sensorlib/hw_isl29023.h"
#include "sensorlib/i2cm_drv.h"
#include "sensorlib/isl29023.h"
#define debug
我的问题是关于最后一行(标记为红色)
我从未见过以这样的方式使用#define ...我习惯了以下内容:
#define debug se_number
这是否是拼写错误?
在不为符号分配值的情况下定义符号仍允许在以下指令中使用:
#if defined (debug) ... #endif
如果您查看编译器命令开关、如下所示。
-mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.4.LTS/include --include_path="C:/ti/TivaWare_C_Series-2.1.4.178 --g --define=debug --define=part_TM4C123GH6PM --define=target_off_error=bloat_display_error=bloat_bid_off-bidag1 -display_error=bulk_off-bulk_display_bulk=bat_display_off-diag=p225-bulk_remot_remot
--define 就像 C 文件中的#define name 一样。 如果省略了 def、则将名称设置为1。 因此、在本例中的调试等于1。 下面是 C TI ARM 编译器用户指南的摘录。
是否可以询问-"什么是"、"要绘制的行"-在授予(仅部分)名称中-"预定义状态?"
难道不会(更好)通过颜色编码(或其他方式)提醒用户注意这种"独特的处理"、而不是要求(更困难和更耗时)搜索并研究对"编译器命令切换"的审查?
供应商代理(以任何方式)都不会创建或煽动此问题、但事实证明、"不太直观!" (也许-要求苛刻。)
不可以、它可以在源文件中定义、但在使用前必须对预处理器可见。
#define debug…… #if defined (debug) ... 其他.... #endif