Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: 8.3-stable
Choose a base branch
from

Conversation

smfc99
Copy link

@smfc99 smfc99 commented Oct 14, 2024

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants