gpt4 book ai didi

C单元错误 : implicit declaration of function 'CU_inizialize_registry'

转载 作者:太空宇宙 更新时间:2023-11-04 04:25:08 25 4
gpt4 key购买 nike

我是 CUnit 的新手,我正在尝试运行示例代码来测试 CUnit 是否正常工作。我有三个文件。

最大高度

    #ifndef MAX_H_
#define MAX_H_

extern int maxi(int, int);

#endif /* MAX_H_ */

最大.c

    #include "max.h"

int maxi (int i1, int i2)
{
return (i1 > i2) ? i1 : i2;
}

和Test_max.c

    #include <stdio.h>
#include <CUnit/CUnit.h>
#include <CUnit/Basic.h>

#include "max.h"

int init_suite(void)
{
return 0;
}

int clean_suite(void)
{
return 0;
}

void testMax(void)
{
CU_ASSERT(maxi(1,2) == 2);
CU_ASSERT(maxi(3,2) == 3);
CU_ASSERT(maxi(2,4) == 4);
}

int main()
{
CU_pSuite pSuite = NULL;

if (CUE_SUCCESS != CU_inizialize_registry())
return CU_get_error();

pSuite = CU_add_suite("Suite di prova", init_suite, clean_suite);
if (NULL == pSuite)
{
CU_cleanup_registry();
return CU_get_error();
}

if (NULL == CU_add_test(pSuite, "Test max", testMax))
{
CU_cleanup_registry();
return CU_get_error();
}

CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}

当我构建时,我收到警告和错误:

  • (warning) warning: implicit declaration of function 'CU_inizialize_registry' is invalid in C99 [-Wimplicit-function-declaration] if (CUE_SUCCESS != CU_inizialize_registry())
  • (error) ld: symbol(s) not found for architecture x86_64

CU_inizialize_registry 有什么问题?我不明白。你可以帮帮我吗?谢谢

更多信息:MacOS 10.12.3、Eclipse、cunit 2.1-3

最佳答案

CU_initialize_registry 而不是 CU_iniZialize_registry(t 而不是 z)呢?

关于C单元错误 : implicit declaration of function 'CU_inizialize_registry' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42432864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com