Go Down

Topic: Difficulties compiling typedefs (Resolved) (Read 3964 times) previous topic - next topic

GoForSmoke

Arduino can handle 64-bit integers, signed and unsigned?!?

I needs a Tex Avery jaw drop smiley! Scuse me while I wander around all goofball for a while.....

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

mrdovey

@GoForSmoke - An (unsigned) long on the Arduino is 32-bits, and an (unsigned) long long is 64-bits. A 32-bit millisecond timer will wrap every 49.7 days - and a 64-bit millisecond timer will wrap approximately every 5 gazillion years. I don't need that much, but I know/hope I'm going to need more than 49 days - so I'll pay the price.

If I included <time.h>, then I'd suck in a definition of time_t - but since I want to ensure 64-bits, I'm not including it. This means I have to provide my own time functions, but that isn't a problem. You aren't as confused as you think you are.  :)

@jwatte - el_supremo identified the source of the errors: the IDE was, effectively, re-ordering source code in such a way as to force errors where there had been none coded. If I weren't so suave and debonaire, I'd probably be REALLY PISSED OFF - but I'm not.   8)

mrdovey

@GoForSmoke - ROFL! Yes, but "handle" doesn't necessarily mean Arduino has 64-bit registers or instructions.   :smiley-mr-green:

GoForSmoke

The only way the wrap should be a problem is if you're watching for durations longer than 49.71... days.

How about time64_t for clarity as well as uniqueness?

Hmmm, I know the ATmega is 8 bit.. by handle I mean actually able to do calculations with, shift, etc.

I have a box in a closet with my late 70's TI programmable calculators, a TI-56 and a TI-59 on print cradle. I believe they're 4-bit machines capable of 20-digit precision, probably using BCD in microcode. Back in 1977 I used the 56 to run the map table while in a US Army radar crew. Months later the Sound-Flash guys all had green TI-56's. I think that by 81 the expected upgrades obsoleted the lot.

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

mrdovey

I could, but I've got a heap of ready-to-use POSIX code that I'm too lazy to change. What I did (between exchanges here) was:

Code: [Select]
#define time_t unsigned long long      /* Define a 64-bit time type           */
#define fptr_t(x) void(*x)()           /* Define a function pointer type      */


which isn't pretty, but takes care of a lot of the non-structure problems. The structure headache came from trying to use the structure tag within the structure typedef. I solved that problem (which shouldn't have been a problem) by coding an "incomplete declaration" and then using the now-known tag in my typedef. Sounds more complicated than it actually is:

Code: [Select]
struct evnt_d                          /* Define a queue element's structure  */
{  struct evnt_d *next;                /*   Pointer to next element           */
   time_t when;                        /*   Scheduled execution time (msec)   */
   fptr_t(what);                       /*   Pointer to callback routine       */
};                                     /* End event structure definition      */
typedef struct evnt_d evnt_t;          /* Define typedef for event structure  */


Which the compiler allowed.

Go Up