Compile errors with error: 'ULONG_MAX' was not declared in this scope

Hi all,

My sketch had been compiling fine on 1.6.3 and suddenly, it gives out this errors

Can anyone give some suggestions on how to fix it ??

"error: 'ULONG_MAX' was not declared in this scope"

I'm using Arduino 1.6.3 and the errors was from the tinyGPS++ library..

By itself, using the TinyGPS++ examples, the sketch compile ok..

C:\Users\stanley\Dropbox\Arduino\libraries\TinyGPSPlus/TinyGPS++.h: In member function 'uint32_t TinyGPSLocation::age() const':
C:\Users\stanley\Dropbox\Arduino\libraries\TinyGPSPlus/TinyGPS++.h:59:83: error: 'ULONG_MAX' was not declared in this scope
    uint32_t age() const    { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }
                                                                                   ^
C:\Users\stanley\Dropbox\Arduino\libraries\TinyGPSPlus/TinyGPS++.h: In member function 'uint32_t TinyGPSDate::age() const':
C:\Users\stanley\Dropbox\Arduino\libraries\TinyGPSPlus/TinyGPS++.h:83:86: error: 'ULONG_MAX' was not declared in this scope
    uint32_t age() const       { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }

tinyGPS++ FulExample compile fine....

Sketch uses 15,534 bytes (50%) of program storage space. Maximum is 30,720 bytes.
Global variables use 764 bytes (37%) of dynamic memory, leaving 1,284 bytes for local variables. Maximum is 2,048 bytes.

My sketch can be found at :-

Is Google broken in your country ?

It's not entirely clear why you are getting this error, but nothing is stopping you from defining it yourself.

#define ULONG_MAX 4294967295UL

It is the biggest value you can have for a 32 bit unsigned integer.

Thanks..

I turn on compile verbose and saw an unused GRBL library included :

Once I removed this GRBL, the compile works fine.. but when I added it back on, the above errors came back..

Weird...

Using library GRBL in folder: ....\Arduino\libraries\GRBL (legacy)

FYI, ULONG_MAX is defined in limits.h. If I do the following I can access ULONG_MAX in my code:

   #include "limits.h"

The original poster had a different issue, but searching for "ULONG_MAX arduino" lead to this page, so I'm leaving this breadcrumb for others.

1 Like