- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在将我在 CodeWarrior v5.2 中开发的应用程序迁移到 Keil uVision v5.25,它使用 ARM C 编译器 v5.06。
在我的代码中,我一直使用 bool
来表示 bool 值,它在我项目的 types.h
文件中定义为:
typedef enum _bool
{
false = 0,
true = 1
} bool;
当我尝试编译我的代码时,编译器生成关于我隐式地将比较结果分配给具有这种类型的变量的行的警告:
src\c\drivers\motor.c(168): warning: #188-D: enumerated type mixed with another type
const bool motorStopped = timeSinceLastEvent > maxPulseWidth;
src\c\drivers\motor.c(169): warning: #188-D: enumerated type mixed with another type
const bool motorStalled = motorStopped && isMotorDriven();
我明白为什么会生成这些警告。我知道我可以通过显式转换为 bool
来抑制这些警告,例如:
const bool motorStopped = (bool)(timeSinceLastEvent > maxPulseWidth);
但是,对每个 bool 条件都这样做是非常难看的。我想知道是否有一种方法可以配置 Keil uVision/ARM 编译器(或修改我的代码)以不生成有关 bool
的警告,而无需完全禁用有关将枚举类型与其他类型混合的警告。
这些是我可以用来配置编译器的选项:
最佳答案
感觉很脏,但我通过修改 SDK 工具包附带的 types.h
文件解决了这个问题,使它包含 stdbool.h
而不是定义它自己的bool
类型。重新编译我的项目在使用 bool
的第三方代码或我自己的代码中均未产生任何警告/错误。
为了更好的衡量,我尝试以一种方式修改它,如果它在 C89 项目中编译,它仍然可以正常工作:
#if __STDC_VERSION__ >= 199901L
#include <stdbool.h>
#endif
// ...
#if __STDC_VERSION__ < 199901L
typedef enum _bool
{
false = 0,
true = 1
} bool;
#endif
关于c - 防止 Keil uVision 中 bool 值的 "enumerated type mixed with another type"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51399856/
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求提供代码的问题必须表现出对所解决问题的最低限度的了解。包括尝试的解决方案、为什么它们不起作用以及预期结果
我动态地将一些代码加载到 RAM 中,并尝试对其进行调试。当在 uVision 中单步执行代码时,它总是会跳过当前项目中不存在的所有代码,并在来自当前项目的第一条指令处停止。这导致它也跳过我的动态加载
我正在尝试构建此代码。但我不知道错误在哪里?我做错了什么? #include "stm32f10x.h" #include "stm32f10x_rcc.h" #include "stm32f10x_
我正在使用uVision 5的教育/评估版本。调试项目时,反汇编窗口会标记要执行的下一条语句,并在页边空白处带有黄色箭头。 到达该行代码后,文本编辑器中每行的空白将变为绿色。这似乎暗示着文本编辑器知道
我想在 Keil uVision 中找到自动对齐快捷键。我尝试了一些快捷键,但我找不到。在 Visual Studio 中我曾经: CTRL + K + D ,但在 keil uVision 中我不知
我正在使用 Keil uVision4 IDE 对 NXP LPC1768 进行编程。我需要组合两个十六进制文件的建议。这两个文件将是一个引导加载程序和一个用于生产编程的应用程序。目前,我能够成功地将
Arduino 有一个delay(ms) 函数来暂停程序一段时间。以毫秒为单位非常准确。 我在用于 AT89C5131 微 Controller 的 Keil uVision 中使用的 C 中有一个延
我是用mbed的在线编译器编程的,但现在我需要调试支持,昨晚我导出到uVision 4。不过我编译官方库时似乎有错误。 mbed/KL25Z/gpio_object.h(33): 警告:#260-D:
我从 Nordic SDK 的 keil 示例项目开始。这个问题不是关于nordic sdk,而是Keil如何连接头文件和源文件。在我能理解的情况下,Keil 隐藏了所有合并到 main.c 文件中的
当我从 main() 调用包含无限循环的 C 函数时,它会在执行该函数之前将一些寄存器压入堆栈。由于该函数包含一个无限循环,因此这些寄存器永远不会被弹出。 举个例子 void My_Func (voi
我正在用 C 语言在 uVision 4 上编码以完成 ARM 作业。我似乎无法弄清楚,但每次我不断收到字符串“536876144”。 int main(void) { int binary[
我正在使用 Keil uVision 4 进行编程。 我有这样的代码: sbit X = P3 ^ 3; // X is third bit of P3 register ... while
我正在做一个使用 Keil uvision 3.0 的旧项目以及带有 arm-uclibc- 前缀的 GNU 编译器和 Cygnus 那些是非常古老的工具,有奇怪的错误。没有不完整的错误语法高亮显示,
我使用的是 STM32F107 cortex m3 微 Controller 。我在该项目中使用 Keil uvision IDE。我有一个在起始位置(即 0x0800 0000)正确运行的应用程序。
我一直在做一个关于家庭自动化的项目,在这个项目中我必须使用带有 8051 微 Controller 的定时器中断。我已经构建了以下代码,但是我无法设法让中断工作。该程序似乎根本没有进入定时器 ISR。
我正在尝试编译这个项目 https://github.com/NordicSemiconductor/nrf51-ble-app-lbs/tree/require-encryption-5.1.0在
我正在设计一个 IIR 二阶低通滤波器,采样频率 = 100Hz,截止频率 = 10Hz。滤波器系数是 Chebyshev Type I,在 Matlab 中使用 fdatool。但是代码无法过滤信号
我正在将我在 CodeWarrior v5.2 中开发的应用程序迁移到 Keil uVision v5.25,它使用 ARM C 编译器 v5.06。 在我的代码中,我一直使用 bool 来表示 bo
我是一名优秀的程序员,十分优秀!