gpt4 book ai didi

c++ - openssl API 的 G++ 编译错误

转载 作者:行者123 更新时间:2023-11-28 00:53:35 26 4
gpt4 key购买 nike

我在使用 G++ 编译器编译 openssl 函数以从公共(public)证书获取到期日期时遇到问题。

错误是,

error: expected unqualified-id before ‘not’ token
error: expected primary-expression before ‘)’ token

编译过程,

g++  main.c -o test -I /usr/include/openssl/ -lcrypto -lssl

包含所有头文件。

下面的代码是我编译的,

 main ()
{
X509 *x;

int n=0;

unsigned char *not; //expected unqualified-id before ‘not’ token ,expected initializer before ‘not’ token
BIO *out;
FILE *fp=fopen("/home/public.cer", "r");

x = X509_new();
x = PEM_read_X509(fp,NULL,NULL,NULL);
fclose(fp);

out = BIO_new(BIO_s_mem());
ASN1_TIME_print(out, X509_get_notAfter(x));//expected primary-expression before ‘)’ token
n = BIO_get_mem_data(out, &not);
expiryStr = (char *) malloc (n+1);
expiryStr[n] = '\0';
memcpy(expiryStr, not, n);//expected primary-expression before ‘)’ token
printf("Expiry Date====================%s\n",expiryStr);
BIO_free(out);

X509_free(x);
}

请帮我解决这个错误。

最佳答案

“not”是 C++ 中的关键字:http://en.cppreference.com/w/cpp/keyword .您必须重命名该变量。

关于c++ - openssl API 的 G++ 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12696240/

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