解决warning: incompatible implicit declaration of built-in function 'strlen'

c语言编译时,对于类似于warning: incompatible implicit declaration of built-in function 'strlen'的警告,可通过添加相应的头文件来消除。

如strlen、strcpy等对字符串的操作函数,需要添加#include <string.h>

如malloc、free等对内存的操作函数,需要添加#include <stdlib.h>

In file included from tpm_sign_example.c:1: /usr/include/tss2/tss2_esys.h:954:25: note: expected ‘TPMT_TK_HASHCHECK **’ {aka ‘struct <anonymous> **’} but argument is of type ‘TPM2B_DIGEST *’ {aka ‘struct <anonymous> *’} 954 | TPMT_TK_HASHCHECK **validation); | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ tpm_sign_example.c: In function ‘verify_signature’: tpm_sign_example.c:89:5: error: unknown type name ‘RSA’ 89 | RSA *rsa = RSA_new(); | ^~~ tpm_sign_example.c:89:16: warning: implicit declaration of function ‘RSA_new’ [-Wimplicit-function-declaration] 89 | RSA *rsa = RSA_new(); | ^~~~~~~ tpm_sign_example.c:89:16: warning: initialization ofint *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] tpm_sign_example.c:90:8: error: request for member ‘n’ in something not a structure or union 90 | rsa->n = BN_bin2bn(pubKey->publicArea.unique.rsa.buffer, pubKey->publicArea.unique.rsa.size, NULL); | ^~ tpm_sign_example.c:90:14: warning: implicit declaration of function ‘BN_bin2bn’ [-Wimplicit-function-declaration] 90 | rsa->n = BN_bin2bn(pubKey->publicArea.unique.rsa.buffer, pubKey->publicArea.unique.rsa.size, NULL); | ^~~~~~~~~ tpm_sign_example.c:91:8: error: request for member ‘e’ in something not a structure or union 91 | rsa->e = BN_new(); | ^~ tpm_sign_example.c:91:14: warning: implicit declaration of function ‘BN_new’ [-Wimplicit-function-declaration] 91 | rsa->e = BN_new(); | ^~~~~~ tpm_sign_example.c:92:5: warning: implicit declaration of function ‘BN_set_word’ [-Wimplicit-function-declaration] 92 | BN_set_word(rsa->e, pubKey->publicArea.parameters.rsaDetail.exponent); | ^~~~~~~~~~~ tpm_sign_example.c:92:20: error: request for member ‘e’ in something not a structure or union 92 | BN_set_word(rsa->e, pubKey->publicArea.parameters.rsaDetail.exponent); | ^~ tpm_sign_example.c:95:15: warning: implicit declaration of function ‘RSA_verify’ [-Wimplicit-function-declaration] 95 | int ret = RSA_verify( | ^~~~~~~~~~ tpm_sign_example.c:96:9: error: ‘NID_sha256’ undeclared (first use in this function) 96 | NID_sha256, | ^~~~~~~~~~ tpm_sign_example.c:96:9: note: each undeclared identifier is reported only once for each function it appears in tpm_sign_example.c:106:5: warning: implicit declaration of function ‘RSA_free’ [-Wimplicit-function-declaration] 106 | RSA_free(rsa); | ^~~~~~~~ tpm_sign_example.c: In function ‘main: tpm_sign_example.c:124:77: warning: implicit declaration of functionstrlen’ [-Wimplicit-function-declaration] 124 | TPMT_SIGNATURE *signature = tpm_sign(ctx, keyHandle, (uint8_t*)message, strlen(message)); | ^~~~~~ tpm_sign_example.c:124:77: warning: incompatible implicit declaration of built-in functionstrlen’ tpm_sign_example.c:4:1: note: include ‘<string.h>’ or provide a declaration ofstrlen’ 3 | #include <stdlib.h> +++ |+#include <string.h>
最新发布
04-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值