The following problem took me several days to track down.
When there is a variable declared in outer scope, say k, and this variable is redeclared in a function, and this function calls another function, which in turn accesses the global variable, then an Error occurs, indicating that probably the inner function tries to access the declaration of k from the calling function instead of the declaration of k from the global scope, which it should.
Example
The following example (based on one of the hashing examples in pepper) compiles with gcc -ansi -c -I. example.c but throws java.lang.RuntimeException: I don't know how to treat type uint bits 32 like a pointer in pequin.
example.h:
#include <stdint.h>
struct In {
uint8_t input;
};
struct Out {
uint8_t out;
};
static const uint32_t k[2] = {0x428a2f98,0x71374491};
example.c:
#include <example.h>
void sha256_transform() {
uint32_t i, t;
for (i = 0; i < 2; ++i) {
t = k[i];
}
}
void sha256_final() {
sha256_transform();
}
void compute(struct In *input, struct Out *output) {
uint32_t k; /* for-loop index variable */
sha256_final();
}
compute() calls sha256_final() which in turn calls sha256_transform() which accesses the global k. But instead it accesses the variable k from the function scope of compute.
To my understanding, the code should compile without errors, but pequin's C Compiler throws I don't know how to treat type uint bits 32 like a pointer.
The following problem took me several days to track down.
When there is a variable declared in outer scope, say
k
, and this variable is redeclared in a function, and this function calls another function, which in turn accesses the global variable, then an Error occurs, indicating that probably the inner function tries to access the declaration ofk
from the calling function instead of the declaration ofk
from the global scope, which it should.Example
The following example (based on one of the hashing examples in pepper) compiles with
gcc -ansi -c -I. example.c
but throwsjava.lang.RuntimeException: I don't know how to treat type uint bits 32 like a pointer
in pequin.example.h
:example.c
:compute()
callssha256_final()
which in turn callssha256_transform()
which accesses the globalk
. But instead it accesses the variablek
from the function scope ofcompute
.To my understanding, the code should compile without errors, but pequin's C Compiler throws
I don't know how to treat type uint bits 32 like a pointer
.