# How can I use 64-bit integers on a PIC18?

When I try to declare either a unsigned long long or a uint64_t the xc8 compiler throws the following warning:

    12: uint64_t overflow_time;
^ (374) missing basic type; int assumed (warning)
^ (314) ";" expected
^ (374) missing basic type; int assumed (warning)


This eventually spirals into an error later in the compilation. Through some research I found that when using the default C90 standard the xc8 compiler doesn't support 64-bit datatypes.

The best solution I could find online was "Upgrade to XC8 2.05" - which I already had.

How can I get the compiler to allow me to use 64 bit datatypes?

• Just don't use 64 bit numbers on the least code efficient CPU still manufactured. Never. If you for reasons unknown need 64 bit resolution, you picked the completely wrong MCU for the task. You are essentially asking how to fit an elephant inside a porcelain store. Just because it is theoretically possible by temporary removing some wall, that doesn't mean it is a good idea or something you should be doing. – Lundin Aug 20 '19 at 14:22
• What in the world are you doing that calls for a 64-bit integer? That's a very big number!! You might be better off asking about achieving what you want to achieve with a smaller integer. – Scott Seidman Aug 20 '19 at 14:43
• @Lundin, that's a strange stipulation. Practically any CPU can handle very large numbers absolutely fine if performance is not a problem, which OP didn't say was a concern. And large data on small or very low cost CPUs is very common. All depends on the requirements of the application, as with every design: cost, availability, performance, familiarity with tools, cost, commonality with other designs, cost. And cost, usually :-) – TonyM Aug 20 '19 at 20:50
• @Lundin Doing some 64 bit addition on my PIC18F47K42 uses <4.5% of the data memory and <1.1% of the program memory... – Harry Beadle Aug 21 '19 at 9:45
• @Lundin, OP's CPU can perform 64-bit addition fine. Or 1024-bit. You're inventing a performance/space problem to solve. The world uses mountains of 8-bit CPUs, some in high-volume, very low-cost applications. They forget MIPS/$, all about tiny$. (We've disagreed about this before and are getting nowhere here. Look wider, it's a far diverser market than just mainstream Europe/US supplier price lists.) – TonyM Aug 21 '19 at 21:33

--std=C99 --ext=cci