[8.3-stable] Resolves naming conflicts between variable names and c++ identifiers-"new" #658
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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;