Hi i have a portion of code that drove me nuts because i couldnt find the reason it was not working. So i opened visual studio and the offending code compiled fine. Please advise if you have the same problem. To complile in Visual Studio the only change i have made was to delete the loop and setup functions and replace it with a main(). I can reproduce the behavior i am hoping someone had the same problem. At first i thought it was a reserved name but i tried other names for the typedef and the result was the same.
I believe this may be an issue with the Arduino IDE's automatic prototype generation - it seems to be incorrectly adjusting for the typedef when it creates the prototype, leading to a multiple-declaration compile error.
Gumpy: That's exactly what i am getting the problem is, if you check the code, the MASK typedef is declared in the beginning of the file: typedef unsigned char MASK; So it seems to be reproducible.
Aeturnalus: I don't quite know the innards of the IDE so i really can't help the community in that .
AWOL: I have corrected that because it is all wrong in fact. If you notice it should be: if (CUR_MILLI % REFRESH_MILLI == 0) Were you talking about this correction or the modulo in general.
AWOL:The answer to tick i lessen the chance of missing it because i take samples and freeze the mili to pass to this functions. Even though it can happen that while some task is being done i may miss one tick but its not critical, unless the execution of other tasks always make it to happen that way. But if i go down that way lots of more logic has to be implemented in a project that is still in the very early stages. Thanks for the nudge even so.
OffTopic:Do you know of a workaround without interrupts? Or direct me to a topic about that?
The #define is a workaround that is ugly in its best considering C does that and the compiler knows it:D
Indeed that compiles just fine but you just commented the function that had that typedef invoked on the parameters which is exactly what is triggering the bug so of course it doesn't show up. I had tried it with different functions that invoke it and it spews the same error. It's not a '}' because that exactly same code compiles just fine in another compiler without the function commented out. If you had found the missing } then it would have been a solved problem, but it isn't. It's just a guess which is wrong (from what i understood). I don't mean this to be offending and i am happy that you took interest.
Like I said, it appears to be a problem with the Arduino IDE's automatic prototype generation: manually replacing the MASK with a 'uint8_t' or an 'unsigned char' works fine, as does compiling it directly with avr-gcc (provided a main function that calls setup and loop).
Although, in this case, you could easily just use an enum instead (and an enum would be a better fit, too).
Yes the enum is a better solution and hadn't changed yet because it's not important.
The problem with the typedef is not critical to my program and i had actually already worked around it with the unsigned char. I just made the post and insisted on some answers so that others can benefit and not waste any unnecessary time.Is there any way to report a bug?
Thanks for the advice regarding what happens to the IDE.