Tongsuo-Project / Tongsuo

铜锁/Tongsuo is a Modern Cryptographic Primitives and Protocols Library
https://www.tongsuo.net
Apache License 2.0
1.16k stars 186 forks source link

[8.3-stable] Resolves naming conflicts between variable names and c++ identifiers-"new" #658

Open smfc99 opened 1 month ago

smfc99 commented 1 month ago

gcc 7.3.1 std17 编译 tongsuo 会产生如下的错误:

ERROR: /root/workspace/CubeNet/src/crypto/BUILD:1:1: C++ compilation of rule '//src/crypto:cube_crypto' failed (Exit 1) gcc failed: error executing command /opt/rh/devtoolset-7/root/usr/bin/gcc -Wextra -Wno-unknown-pragmas -Wno-unused-parameter -Wno-deprecated-declarations -Wno-implicit-fallthrough -Wno-unused-private-field -Wignored-qualifiers ... (remaining 405 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox In file included from src/crypto/impl/local/grte_sm2_signer_v1.cpp:17:0: external/tongsuo_8_3_2/include/crypto/evp.h:140:21: error: expected unqualified-id before 'new' EVP_KDF_IMPL (new) (void); ^~~ external/tongsuo_8_3_2/include/crypto/evp.h:140:21: error: expected ')' before 'new' external/tongsuo_8_3_2/include/crypto/evp.h:140:20: error: expected ';' at end of member declaration EVP_KDF_IMPL (new) (void); ^ external/tongsuo_8_3_2/include/crypto/evp.h:140:21: error: expected unqualified-id before 'new' EVP_KDF_IMPL (new) (void); ^~~ cc1plus: error: unrecognized command line option '-Wno-unused-private-field' [-Werror] cc1plus: all warnings being treated as errors Target //example/cube_node:cube_node failed to build Use --verbose_failures to see the command lines of failed build steps.

原因是:tongsuo 是 c 语言实现的,结构体 EVP_KDF_METHOD 里面的变量命名为 new 会和 c++ 中的标识符 new 产生命名冲突。 / struct evp_kdf_impl_st is defined by the implementation / typedef struct evp_kdf_impl_st EVP_KDF_IMPL; typedef struct { int type; EVP_KDF_IMPL (new) (void); void (free) (EVP_KDF_IMPL impl); void (reset) (EVP_KDF_IMPL impl); int (ctrl) (EVP_KDF_IMPL impl, int cmd, va_list args); int (ctrl_str) (EVP_KDF_IMPL impl, const char type, const char value); size_t (size) (EVP_KDF_IMPL impl); int (derive) (EVP_KDF_IMPL impl, unsigned char *key, size_t keylen); } EVP_KDF_METHOD;

CLAassistant commented 1 month ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.