Code: Select all
struct stuff {
mutex m,n;
byte b, c;
};
mutex p;
stuff MyStuff;
void stuffit(stuff &q) {
q.b = q.c;
q.n = q.m;
Acquire(p);
Acquire(q.m);
}
task main() {
stuffit(MyStuff);
Acquire(MyStuff.m);
}
Code: Select all
struct stuff {
mutex m,n;
byte b, c;
};
mutex p;
stuff MyStuff;
void stuffit(stuff &q) {
q.b = q.c;
q.n = q.m;
Acquire(p);
Acquire(q.m);
}
task main() {
stuffit(MyStuff);
Acquire(MyStuff.m);
}
http://cache.lego.com/upload/contentTem ... B2A1F6.pdfThe NXT firmware stores mutex records as flat 32-bit data structures. However, mutex records
are not treated as normal scalar values, and you cannot store mutex records in arrays or clusters.
The only two instructions that can operate legally on mutex records are OP_ACQUIRE and
OP_RELEASE. Refer to the Instruction Reference section of this document for information about
these functions
If you wanted to pass a mutex as an argument that would require the MOV opcode or some other kind of opcode that does not exist.The only two instructions that can operate legally on mutex records are OP_ACQUIRE and OP_RELEASE
Do you mean like "a pointer to a function"?nxtboyiii wrote:Since were talking about structs, will having functions inside a struct ever be possible?
NXC coding philosophy question: I have a 4 line macro. One of the lines calls a subroutine. The subroutine has 1 local variable, 3 lines of C, and 3 lines of asm. What do I do with the subroutine - a) include it in the macro; b) make it inline; or c) make it a safecall. I think a) and b) wind up generating exactly the same amount of code inline. c) has less total code, but involves the additional overhead of: 1) the safecall mutex, 2) handing 5 parameters (one of which is a string) from the macro into the sub. As an ex-performance analyst, I'm torn between them.afanofosc wrote:You can pass a mutex into a preprocessor macro that pretends to be a function. It will be a lot like an inline function.
Code: Select all
struct a {
string b;
string c[];
};
a aa;
string d[];
string e;
long l;
task main() {
e = FlattenVar(l); // This works.
d[0] = FlattenVar(l); // So does this.
aa.b = FlattenVar(l); // And, yet again, it works.
aa.c[0] = e; // This doesn't work.
aa.c[0] = FlattenVar(l); // Neither does this.
}
Users browsing this forum: Semrush [Bot] and 1 guest