NXC: syntax for passing a struct to a function?
Posted: 15 Feb 2011, 19:17
hi,
I try to pass a structure to a function but I don't succeed- what is the right NXC syntax? (edit: the code is an excerpt from an original C file)
I try to pass a structure to a function but I don't succeed- what is the right NXC syntax? (edit: the code is an excerpt from an original C file)
Code: Select all
void DBG () {
return;
}
/* */
/* Complex Numbers. */
/* ================ */
/* complex number */
struct C {
float re,
im;
} ;
/* multply real, complex */
#define C_MUL( f, z) \
do { \
z.re *= f; z.im *= f; \
} while (FALSE)
/* complex product constructor */
#define C_PRO( z1, z2) { \
re: z1.re * z2.re - z1.im * z2.im, \
im: z1.re * z2.im + z1.im * z2.re \
}
/* bit reverse permutation */
void BRP (unsigned char ldN,
struct C vec []) /* 2^ldN */ // <<========================== ERROR !
{
unsigned int N;
unsigned int l, n, r;
unsigned char b;
N = 1 << ldN;
for (l = 0; N > l; ++ l)
{
n = l;
r = 0;
for (b = 0; ldN > b; ++ b) {
r <<= 1;
if (0 != 1 & n ) { r |= 1; }
n >>= 1;
} // b
if (l < r) {
struct C const z = vec [l];
vec [l] = vec [r];
vec [r] = z;
} // right
} // k
return;
} // BRP
task main() {
}
# Error: Unexpected character encountered
File "c:\Temp\temp.nxc" ; line 30
# struct C v
#----------------------------------------------------------
# Error: Variable name expected
File "c:\Temp\temp.nxc" ; line 30
# struct C v
#----------------------------------------------------------
# Error: Unknown datatype
File "c:\Temp\temp.nxc" ; line 30
# struct C v
#----------------------------------------------------------
# Error: Variable name expected
File "c:\Temp\temp.nxc" ; line 32
# unsigned int const N
#----------------------------------------------------------
# Error: ';' expected
File "c:\Temp\temp.nxc" ; line 32
# unsigned int const N =
#----------------------------------------------------------