Page 1 of 1
Converting from C, need help
Posted: Tue Mar 24, 2009 4:54 pm
by Seymour Clufley
Can anyone tell me what "static inline void" would translate to in PB?
And would this:
translate to:
?
The code is mostly wrapped inside a "namespace". Should I just ignore that?
Re: Converting from C, need help
Posted: Tue Mar 24, 2009 9:54 pm
by Trond
Seymour Clufley wrote:Can anyone tell me what "static inline void" would translate to in PB?
That's the return type of a function, right? Then it would be nothing in PB:
And would this:
translate to:
?
No. The C array is static with 16 elements, while the PB array is dynamic with 17 elements. Having one element too much usually won't hurt, though.
The code is mostly wrapped inside a "namespace". Should I just ignore that?
Yes.
Posted: Tue Mar 24, 2009 11:10 pm
by Seymour Clufley
Thanks, Trond! That's very helpful.
Could you also explain some other parts...
"m4" is a namespace, "id" is a function and "s" is a double array. So, in PB speak, is that code simply calling a procedure?
The code has a line "include assert.h" and this is the only line of code that makes use of it. If I understand Wikipedia correctly, assert.h is just a debugging macro. So again, can I just ignore this?
Code: Select all
for(size_t j=0; j<4; ++j)
{
for(size_t i=0; i<4; ++i)
{
printf(m[i+4*j]);
}
}
It's the first line I'm not sure of, as it seems to be using two variables (size_t and j) instead of just one.
Thanks again for your help, Trond.
Posted: Tue Mar 24, 2009 11:13 pm
by Hroudtwolf
I suggest, this is the true PB equivalent to an static array in C....
Code: Select all
Structure tDoubleArray
nValue.d [ 16 ]
EndStructure
Define.tDoubleArray MyArray
MyArray\nValue [ 0 ] = 1
Regards
Wolf
Posted: Wed Mar 25, 2009 12:15 pm
by Psychophanta
Depending on what to do, for some cases, in PB i would do:
Code: Select all
DataSection
!s:
!rq 16
EndDataSection
And then refer to s label as it was the variable.
Posted: Wed Mar 25, 2009 3:14 pm
by Trond
size_t is just the typename and means j is of the type size_t (which is probably the same as unsigned long int).