c++ - 如何使用 clang-tidy 修复预期的 unqualified-id 错误
问题描述
我有以下嵌入式系统的 c++ 代码:
//LIBRARY code:
typedef struct { /*!< (@ 0x48028100) PORT1 Structure */
__IO uint32_t OUT; /*!< (@ 0x48028100) Port 1 Output Register */
__O uint32_t OMR; /*!< (@ 0x48028104) Port 1 Output Modification Register */
__I uint32_t RESERVED[2];
__IO uint32_t IOCR0; /*!< (@ 0x48028110) Port 1 Input/Output Control Register 0 */
__IO uint32_t IOCR4; /*!< (@ 0x48028114) Port 1 Input/Output Control Register 4 */
__IO uint32_t IOCR8; /*!< (@ 0x48028118) Port 1 Input/Output Control Register 8 */
__IO uint32_t IOCR12; /*!< (@ 0x4802811C) Port 1 Input/Output Control Register 12 */
__I uint32_t RESERVED1;
__I uint32_t IN; /*!< (@ 0x48028124) Port 1 Input Register */
__I uint32_t RESERVED2[6];
__IO uint32_t PDR0; /*!< (@ 0x48028140) Port 1 Pad Driver Mode 0 Register */
__IO uint32_t PDR1; /*!< (@ 0x48028144) Port 1 Pad Driver Mode 1 Register */
__I uint32_t RESERVED3[6];
__I uint32_t PDISC; /*!< (@ 0x48028160) Port 1 Pin Function Decision Control Register */
__I uint32_t RESERVED4[3];
__IO uint32_t PPS; /*!< (@ 0x48028170) Port 1 Pin Power Save Register */
__IO uint32_t HWSEL; /*!< (@ 0x48028174) Port 1 Pin Hardware Select Register */
} PORT1_Type;
#define PORT1_BASE 0x48028100UL
#define PORT1 ((PORT1_Type *) PORT1_BASE)
// MY MINIMAL EXAMPLE CODE:
...
uint32_t u32SourceAddress = (uint32_t)(&(PORT1->IN)), // error: expected unqualified-id
// ^
...
当我用 GCC 或 ARMCC 编译这段代码时,它工作得很好。当我使用 clang-tidy 时,我收到一个错误:expected unqualified-id [clang-diagnostic-error] 就可以了。我做错了什么,我该如何解决?
谢谢,莫里茨
编辑:添加了关于基于库的代码和我的代码的评论。
解决方案
推荐阅读
- image - 如何显示我已转换的文件数量?
- c - C、快速在数组元素中进行乘法的方法
- python - 保留第一行的所有列值以及 Pandas 组中后续行的任何更新?
- c# - Dotnet Core 3.1 控制台应用程序托管可选的 Web API 以进行控制
- .net-core - OpenSSL 创建的证书颁发机构适用于 Windows 10,但不适用于 Ubuntu
- python - python类对象不可序列化
- c++ - 带有着色器程序且没有错误的现代 OpenGL 黑屏
- python - Python - 如何将类似字典的字符串转换为字典
- java - Com.example 有错误的路径
- vb.net - vb.net 应用程序。我在第 89 行有问题(如果 dt.Rows.Count >0)不起作用我该怎么办?