Browse Category: Compiling

error: ‘ptrdiff_t’ was not declared in this scope

You will see this error while compiling sources of many packages. This is due to the changes in the recent version of the gcc compiler (for example when you migrate from ubuntu 12.04 to ubuntu 14.04).

To bypass this problem add std:: namespace to ptrdiff_t . That is replace ptrdiff_t with std::ptrdiff_t and there should be no problems given that you have included all the necessary headers.

However, instead of adding an std:: to all the occurrances of ptrdiff_t, one can also use the line using std::ptrdiff_t; at the beginning of the source file.