简体   繁体   English

为OpenSSL库创建名称空间?

[英]Creating a name space for OpenSSL Library?

Is it possible to create a separate namespace when compiling the OpenSSL Lib? 编译OpenSSL Lib时是否可以创建一个单独的命名空间? I'm using https://github.com/x2on/OpenSSL-for-iPhone . 我正在使用https://github.com/x2on/OpenSSL-for-iPhone

The reason I need this is because the current SDK I'm building uses OpenSSL, but when I pass it to the customer, they also uses a different version of OpenSSL, and it is causing duplicate symbol linker errors. 我之所以需要它,是因为我正在构建的当前SDK使用OpenSSL,但是当我将其传递给客户时,他们也使用了不同版本的OpenSSL,这会导致重复的符号链接器错误。

Another question is there a different way for the customer to use our existing SDK without defining our own name space for the OpenSSL Lib? 另一个问题是,客户有没有其他方法来使用我们现有的SDK,而无需为OpenSSL Lib定义我们自己的名称空间?

OpenSSL is a C library. OpenSSL是一个C库。 And C does not support namespaces. C不支持名称空间。

If you really have naming conflicts, best way to handle this is using a wrapper library. 如果您确实有命名冲突,则解决此问题的最佳方法是使用包装器库。

Just as illustration a small example. 就像一个小例子一样。

wrapper.h: wrapper.h:

void xxxxxOpenSSLFunction1();
void xxxxxOpenSSLFunction2();
void xxxxxOpenSSLFunction3();

wrapper.cpp 包装器

#include <OpenSSL...>
#include <OpenSSL...>

void xxxxxOpenSSLFunction1() { OpenSSLFunction1(); }
void xxxxxOpenSSLFunction2() { OpenSSLFunction2(); }
void xxxxxOpenSSLFunction3() { OpenSSLFunction3(); }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM