static uint16_t _lasttime, uint16_t _thistime
is illegal. You might be able to do some strange things with a struct though:
#define runAfter(n) for (struct { static uint16_t last; uint16_t now; } _rA = {0, millis()}; _rA.now - _rA.last >= (n); _rA.last += (n))
That doesn't work either, though: static means something different there.
I also think that runEvery is a better name because it reads "Run every 500" (ms) which is exactly what it does. runAfter imples it only runs once, and has a built in delay.
_thistime is unnecessary if you do the += (n) trick, since then millis() wil only be called once.
so this is what I'm thinking of:
#define runEvery(t) for (static uint16_t _lasttime; millis() - _lasttime > (t); _lasttime += (t))
which is tested and works on my uno.
Thanks for checking it out though --- hopefully a macro like this one will be useful to others.