So, I'm trying to create a class to subclass and allow for a simplistic run loop to allow me to simulate "threads." Each item will have the ability to basically say "don't run again for xx microseconds." For this, I need the "micros()" function.
So I have a C++ object:
class RunLoopItem
{
public:
RunLoopItem ( ) :
runTime ( 0 )
{
}
~RunLoopItem ()
{
}
void run ()
{
if ( 0>runTime )
reallyRun() ;
}
private:
virtual void reallyRun ()
{
}
UInt32 runTime ;
} ;
In the "run" method, if I replace "0" with "micros()", I get an error:
In member function 'void RunLoopItem::run()':
...And that's it... Anyone know why this is?
Some notes:
--> It compiles just fine with the "0" in place
--> "UInt32" is typedef'd to "unsigned long." I picked it up from programming with the CoreFoundation and like it because it's very clear...
--> NO "C" function will work when placed inside a C++ method... "malloc," which works in "loop" and "setup," does not work in the method, even though the method ".h" file is included within the same file as the "setup" and "loop" functions
Also, if you get error messages like that which seem to have the details missing, try turning on build.verbose in the preferences file--although you might also need to try to compile outside the IDE as I recall...
It seems the IDE has problems parsing some kinds of error messages.
Do you really need malloc? When you've only got 2048 (or 1024) bytes of ram, the overhead of using memory allocation is usually not worth it. I betcha you could do it without malloc() or new(). Can you show what you need it for?