G++ compilation erro for openssl API



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

错误是,

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] = '';
        memcpy(expiryStr, not, n);//expected primary-expression before ‘)’ token
    printf("Expiry Date====================%sn",expiryStr);
        BIO_free(out);
        X509_free(x);        
}

请帮助我解决此错误。

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

最新更新