在Windows环境中使用 X509_NAME时,会因为include的顺序导致冲突。
如先
#include "openssl/x509.h"
#include "windows.h"
X509_NAME *Name = X509_get_subject_name(p); //就会发生冲突 ,在windows中定义为 #define X509_NAME ((LPCSTR) 7) 跟openssl的不一致。
因此需要调换#include 的顺序,用openssl/x509.h 覆盖wincrypt.h中的X509_NAME。
#include "windows.h"
...
#include "openssl/x509.h"
另外在类里面,如果只导入 #include "openssl/x509.h" ,会出现 ”未定义的标识符“,也需要#include ”windows.h"。 此时才顺利编译成功。
本文介绍了一个在Windows环境下使用OpenSSL库时遇到的X509_NAME宏定义冲突问题。当包含顺序不当时,会导致编译错误。通过调整包含文件的顺序可以解决此问题,并确保同时兼容Windows和OpenSSL。
4668

被折叠的 条评论
为什么被折叠?



