cpp:预期 primary-expression 在“.”标记之前
cpp: expected primary-expression before ‘.’ token
我有以下代码:
class SSLHashSHA1
{
SSLHashSHA1();
~SSLHashSHA1();
public:
static OSStatus update(string*, int*);
static OSStatus final (string*, string*);
};
OSStatus SSLHashSHA1::update(string* ctx, int* ran){
return 0;
}
OSStatus SSLHashSHA1::final(string* ctx, string* out){
return 0;
}
static OSStatus SSLVerifySignedServerKeyExchange(
SSLContext *ctx, bool isRsa, SSLBuffer signedParams, uint8_t *signature, uint16_t signatureLen)
{
OSStatus err;
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;
fail:
SSLFreeBuffer(&signedHashes);
SSLFreeBuffer(&hashCtx);
return err;
}
我收到标题中提到的错误。
我得到了 SSLHashSHA1.update 和 SSLHashSHA1.final 调用。
我为什么会这样?
我认为当我将 class 成员函数设置为静态时,我可以使用而不必创建 object。或者我应该将 class 更改为结构或类似的东西吗?
SSLHashSHA1.update()
这是完全错误的,SSLHashSHA1
是一个class,不是一个实例,所以你不能在这里使用.
运算符来调用方法,因为你提到,您的 update
是一个静态函数,因此使用 scope-resolution 运算符 (::
) 调用它,如下所示:
SSLHashSHA1::update(&hashCtx, &serverRandom))
我有以下代码:
class SSLHashSHA1
{
SSLHashSHA1();
~SSLHashSHA1();
public:
static OSStatus update(string*, int*);
static OSStatus final (string*, string*);
};
OSStatus SSLHashSHA1::update(string* ctx, int* ran){
return 0;
}
OSStatus SSLHashSHA1::final(string* ctx, string* out){
return 0;
}
static OSStatus SSLVerifySignedServerKeyExchange(
SSLContext *ctx, bool isRsa, SSLBuffer signedParams, uint8_t *signature, uint16_t signatureLen)
{
OSStatus err;
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;
fail:
SSLFreeBuffer(&signedHashes);
SSLFreeBuffer(&hashCtx);
return err;
}
我收到标题中提到的错误。 我得到了 SSLHashSHA1.update 和 SSLHashSHA1.final 调用。 我为什么会这样?
我认为当我将 class 成员函数设置为静态时,我可以使用而不必创建 object。或者我应该将 class 更改为结构或类似的东西吗?
SSLHashSHA1.update()
这是完全错误的,SSLHashSHA1
是一个class,不是一个实例,所以你不能在这里使用.
运算符来调用方法,因为你提到,您的 update
是一个静态函数,因此使用 scope-resolution 运算符 (::
) 调用它,如下所示:
SSLHashSHA1::update(&hashCtx, &serverRandom))