- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这里的目标是帮助人们在使用 C++ 进行开发时捕获嵌入式系统上的一些错误。作为其中的一部分,我正在尝试让 clang-tidy 为小型嵌入式目标工作。
我正在尝试设置 CMake 以执行以下操作:
但是,clang-tidy 失败并显示“未知 objective-c PU 'armv6-m”
--
我用过的CMake脚本如下:
ClangTidy.cmake
set(ENABLE_CLANG_TIDY ON CACHE BOOL "Add clang-tidy automatically to builds")
if (ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "C:\\Program Files\\LLVM\\bin\\clang-tidy.exe")
if (CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set(CLANG_TIDY_CHECKS "-*,modernize-*")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*'"
CACHE STRING "" FORCE)
else()
message(AUTHOR_WARNING "clang-tidy not found!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
endif()
endif()
armv6-m 是 CMake 脚本的一部分,但它仅用于 GCC,以下用于设置 GCcflags:
set(TARGET STM32F070x6)
set(ARCH armv6-m)
set(CORE cortex-m0)
set(CMAKE_CXX_FLAGS "-march=${ARCH} -mcpu=${CORE} -D${TARGET}")
然后构建以下内容:
#
# Including extra cmake rules
include(cmake/ClangTidy.cmake)
#Compile and link the exe :)
add_executable(${TARGET}.elf ${MAIN_SOURCE})
#Print the size of the .hex
add_custom_target(size ALL arm-none-eabi-size ${TARGET}.elf DEPENDS ${TARGET}.elf)
add_custom_target(${TARGET}.bin ALL DEPENDS ${TARGET}.elf COMMAND ${CMAKE_OBJCOPY} -Obinary ${TARGET}.elf ${TARGET}.bin)
cmake 构建生成的构建消息是:
[build] "C:\Program Files\CMake\bin\cmake.exe" -E __run_co_compile
--tidy="C:/Program Files/LLVM/bin/clang-tidy.exe;-checks=-*,modernize-*;-header-filter='G:/Files/Git/projectname/*'" --source=../src/main.cpp
-- C:\PROGRA~2\GNUTOO~1\82018-~1\bin\AR10B2~1.EXE -DHSE_VALUE=48000000 -DSTM32F070x6 -DTRACE -DUSE_STDPERIPH_DRIVER -I../include -I../system -I../library -I../library/usb -I../library/usb/HID -I../library/usb/LL -I../library/usb/Standard -I../library/usb/Types -I../library/common -I../library/common/SCPI -I../library/common/containers -I../library/peripherals -I../library/peripherals/Bitbanging -I../st-library/include -I../st-library/include/arm -I../st-library/include/cmsis -I../st-library/include/cortexm -I../st-library/include/diag -I../st-library/include/stm32f0-stdperiph -march=armv6-m -mcpu=cortex-m0 -DSTM32F070x6 -Os -mthumb -g2 -ggdb -pedantic -Wall -Wextra -Wfloat-equal -Wshadow -Wall -Wl,--gc-sections -fmessage-length=0 -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -std=c++1z -fno-rtti -fno-exceptions -fno-use-cxa-atexit -fno-threadsafe-statics -ftemplate-backtrace-limit=0 -O2 -g -DNDEBUG -MD -MT CMakeFiles/STM32F070x6.elf.dir/src/main.cpp.obj -MF CMakeFiles\STM32F070x6.elf.dir\src\main.cpp.obj.d -o CMakeFiles/STM32F070x6.elf.dir/src/main.cpp.obj -c ../src/main.cpp
在上述错误发生后立即:
[build] error: unknown target CPU 'armv6-m' [clang-diagnostic-error]
[build] note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cannonlake, icelake-client, icelake-server, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
目标 ( armv6-m ) 字段似乎与 GCC 使用的相同。但我不确定为什么要使用目标字段调用 clang-tidy。
最佳答案
在源码中我们可以看到:
static int HandleTidy(const std::string& runCmd, const std::string& sourceFile,
const std::vector<std::string>& orig_cmd)
{
// Construct the clang-tidy command line by taking what was given
// and adding our compiler command line. The clang-tidy tool will
// automatically skip over the compiler itself and extract the
// options.
int ret;
std::vector<std::string> tidy_cmd = cmExpandedList(runCmd, true);
tidy_cmd.push_back(sourceFile);
tidy_cmd.emplace_back("--");
cmAppend(tidy_cmd, orig_cmd);
所以我想说,所有编译器选项,即 CMAKE_CXX_FLAGS 也默认传递给 clang-tidy...
关于c++ - 带有 CMake 和嵌入式目标的 clang-tidy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57851621/
这个问题困扰了我几天。 这是我的相关 Storyboard布局: 我已经将阳光下的每个布局都设置为所有三个 View Controller ,并且仍然得到一个在横幅 View 上方有一个“间隙”的结果
我正在我的 C++ 程序中嵌入一个网页。我遇到的问题是,在嵌入式页面的 javascript 中,我可以捕获 onkeypress,但不会触发 onkeydown 和 onkeyup。 如果我在非嵌入
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 5年前关闭。 Improve this qu
我有一个 java web 应用程序。我想创建一个嵌入式 LDAP 服务器,当 web 应用程序运行时,我将向 LDAP 插入一些记录,并且有另一个 web 应用程序将访问此 LDAP 以获取信息。可
我正在尝试通过 tomcat maven 插件将 war 部署到嵌入式 tomcat 服务器。控制台显示服务器启动正常。 看来 war 还没有展开。当我访问 http://localhost:9090
假设我有如下函数: bigrams=[(k,v) for (k,v) in dict_bigrams.items() if k[:pos_qu]==selection[:pos_qu
我读过一些关于 python 嵌入式 C++ 的教程。我曾引用过 python 对象。 https://docs.python.org/3/c-api/function.html Python 脚本:
我正在使用嵌入式应用程序,在调试期间,调试器无法解析宏符号(我的理论:因为宏在预处理中丢失了)。我最终不得不先在源代码中找到宏,然后使用定义来监视变量。 我的问题是:有没有办法将宏定义合并到 elf
首先我要说的是我开发的是基于cortex m4的嵌入式设备应用。 我有引导加载程序和主应用程序通用的功能。现在我为引导加载程序和应用程序编译源文件 2 次。但是我的双库 dfu 空间不足,我想在 RO
作为嵌入式 C 编程的初学者,我很好奇每个(根据我的经验)程序执行是如何从 main() 函数开始的?这就像链接器识别 main() 并将那个“特殊” 函数的地址放入重置 vector 指向的地址。
在我的实时嵌入式处理器固件中,我需要十进制数字的格式化打印。标准 printf/sprintf 在工具链中不可用,所以我需要自己实现它。 我使用了除以十并取余的天真方法。但是我的目标处理器本身不支持除
我有编程经验,但在软件开发方面了解不多。我目前正在为我工作的公司编写一个软件,我开始挑战自己代码的可读性。 我想知道这是否是嵌入式 if 语句的“有效”替代方案,或者我是否可以使用更好的方法。 假
我有一个运行嵌入式 Linux 的嵌入式目标,我想计算以下时间: 1) 高速缓存读/写时序2) uncache 内存读/写时序 Linux 中是否有任何标准测试来计算上述时间? 我已经编写了自己的测试
大多数嵌入式设备都是为了在通常资源受限或低规格的设备上执行特定任务而构建的。 因此,大多数嵌入式开发人员需要去除不必要的库和模块,并为其特定设备和用例创建自定义分发。我们先来了解一下嵌入式 Linu
我正在嵌入式处理器上编写一个简单的裸机应用程序。作为此应用程序的一部分,它必须使用 malloc 在大约 256kB 的堆上分配一些内存。注意:最初这是在 main 中静态分配的,但在一定的大小限制下
我正在尝试为我 friend 的婚礼建立一个网站。我使用的是 Bootstrap 5,嵌入的视频没有填满屏幕大小。这是一个 live test page HTML: 您还需要代码吗?我想让视频的全宽
我有一个项目,我尝试为微 Controller 构建固件并尝试更好地控制所使用的优化标志。我想,而不是使用 -O flag 分别指定不同的优化标志。不幸的是,-O 似乎发生了一些优化魔法。我无法使用单
我正在使用双核设备,并且要求核心 A 创建一个数据结构,其中包含在核心 B 上运行的函数列表的参数,定期更新它并通知核心 B。参数和类型的数量可以改变在运行期间。 我的计划如下.. 创建一个 Para
我们有一个 Microsoft.Phone.Controls.WebBrowser内嵌控件 StackPanel , 在 PivotItem 内在 Windows Phone 8 上。以简化的形式,它
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 2 年前。 Improve this ques
我是一名优秀的程序员,十分优秀!