CMockery 编译未知类型名称 "jmp_buf"
CMockery Compilation unknown type name "jmp_buf"
我正在尝试将单元测试框架 cMockery 添加到我的 C 项目中。我已经将 cMockery 下载并安装到全局包含路径中。但是在我的源文件中 #include <cmockery.h>
之后,cmake 抛出了以下问题。如果我也使用 cMocka
似乎也会抛出同样的东西。我错过了一些包裹吗?
编辑:Google 搜索 "/usr/include/google/cmockery.h:365:8: error: unknown type name ‘jmp_buf’"
正好返回 0 个结果(现在有 1 个结果指向这个问题)。以及搜索 unknown type name 'jmp_buf'
只解释它是什么。不是如何修复它或为什么它会在 cmockery 中发生。
/usr/bin/cmake --build /home/.../data-structures-c/cmake-build-debug --target data_structures_c -- -j 3
Scanning dependencies of target data_structures_c
[ 50%] Building C object CMakeFiles/data_structures_c.dir/main.c.o
In file included from /home/.../data-structures-c/main.c:3:
/usr/include/google/cmockery.h:365:8: error: unknown type name ‘jmp_buf’
extern jmp_buf global_expect_assert_env;
^~~~~~~
make[3]: *** [CMakeFiles/data_structures_c.dir/build.make:63: CMakeFiles/data_structures_c.dir/main.c.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:73: CMakeFiles/data_structures_c.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/data_structures_c.dir/rule] Error 2
make: *** [Makefile:118: data_structures_c] Error 2
OS:Manjaro Archlinux
Cmake、make、gcc、g++ 全部安装。
我的 CMakeList.txt
也是非常标准的,最低限度只有一个 c 源代码
cmake_minimum_required(VERSION 3.12)
project(data_structures_c C)
set(CMAKE_C_STANDARD 99)
add_executable(data_structures_c main.c)
我想知道如何解决这个问题以便编译我的代码。
根据google/cmockery.hheader开头的评论:
/*
* These headers or their equivalents should be included prior to including
* this header file.
*
* #include <stdarg.h>
* #include <stddef.h>
* #include <setjmp.h>
*
* This allows test applications to use custom definitions of C standard
* library functions and types.
*/
在 包括这个 header 之前,应该 include 在 headers:
之后
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
只有包含这些后才允许
#include <google/cmockery.h>
我正在尝试将单元测试框架 cMockery 添加到我的 C 项目中。我已经将 cMockery 下载并安装到全局包含路径中。但是在我的源文件中 #include <cmockery.h>
之后,cmake 抛出了以下问题。如果我也使用 cMocka
似乎也会抛出同样的东西。我错过了一些包裹吗?
编辑:Google 搜索 "/usr/include/google/cmockery.h:365:8: error: unknown type name ‘jmp_buf’"
正好返回 0 个结果(现在有 1 个结果指向这个问题)。以及搜索 unknown type name 'jmp_buf'
只解释它是什么。不是如何修复它或为什么它会在 cmockery 中发生。
/usr/bin/cmake --build /home/.../data-structures-c/cmake-build-debug --target data_structures_c -- -j 3
Scanning dependencies of target data_structures_c
[ 50%] Building C object CMakeFiles/data_structures_c.dir/main.c.o
In file included from /home/.../data-structures-c/main.c:3:
/usr/include/google/cmockery.h:365:8: error: unknown type name ‘jmp_buf’
extern jmp_buf global_expect_assert_env;
^~~~~~~
make[3]: *** [CMakeFiles/data_structures_c.dir/build.make:63: CMakeFiles/data_structures_c.dir/main.c.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:73: CMakeFiles/data_structures_c.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/data_structures_c.dir/rule] Error 2
make: *** [Makefile:118: data_structures_c] Error 2
OS:Manjaro Archlinux
Cmake、make、gcc、g++ 全部安装。
我的 CMakeList.txt
也是非常标准的,最低限度只有一个 c 源代码
cmake_minimum_required(VERSION 3.12)
project(data_structures_c C)
set(CMAKE_C_STANDARD 99)
add_executable(data_structures_c main.c)
我想知道如何解决这个问题以便编译我的代码。
根据google/cmockery.hheader开头的评论:
/*
* These headers or their equivalents should be included prior to including
* this header file.
*
* #include <stdarg.h>
* #include <stddef.h>
* #include <setjmp.h>
*
* This allows test applications to use custom definitions of C standard
* library functions and types.
*/
在 包括这个 header 之前,应该 include 在 headers:
之后#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
只有包含这些后才允许
#include <google/cmockery.h>