• Welcome to forex.pm forex forum binary options trade. Please login or sign up.
 

secp256k1 lib compiling issue "invalid use of incomplete type secp256k1_context"

Started by Bitcoin, Mar 01, 2022, 05:40 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bitcoin

secp256k1 lib compiling issue "invalid use of incomplete type secp256k1_context"

I make a small test code (test.cpp), try to show the problem I meet:
to compile use


g++ -o test test.cpp -lsecp256k1


#include <stdio.h>
#include "secp256k1.h"

static secp256k1_context_t *ctx = NULL;

int main(int argc, char **argv) {

ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN);
printf("Context created!\n");
secp256k1_context_t *ctx_clone;
ctx_clone = secp256k1_context_clone(ctx);
printf("Context cloned!\n");

/* if enable below two lines of code the compliling error will happen */
// secp256k1_ecmult_context_t* clone_ecm_ctx;
// secp256k1_ecmult_context_clone(clone_ecm_ctx, &ctx->ecmult_ctx);

secp256k1_context_destroy(ctx_clone);
secp256k1_context_destroy(ctx);
printf("Context destroyed!\n");

return 0;
}

Without the two comments out code I will not have issue.
If with two comments out code, the complier will report that:


test.cpp:15:51: error: invalid use of incomplete type 'secp256k1_context_t {aka struct secp256k1_context_struct}'
 secp256k1_ecmult_context_clone(clone_ecm_ctx, &ctx->ecmult_ctx);
                                                   ^~
In file included from test.cpp:2:0:
/usr/local/include/secp256k1.h:50:16: note: forward declaration of 'secp256k1_context_t {aka struct secp256k1_context_struct}'
 typedef struct secp256k1_context_struct secp256k1_context_t;
                ^~~~~~~~~~~~~~~~~~~~~~~~

That looks like I can not operate the context struct internal member (because of the opaque struct), however, my code indeed need to access the struct inside of the context struct, for exp, the below code will trig a similar compiling error:


secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &r1, &s1, &q, &m)


is there any workaround there?


Source: secp256k1 lib compiling issue "invalid use of incomplete type secp256k1_context"