Search code examples
cheaderincludelimit

Difference between #include <limits.h> and #inlcude <linux/limits.h>


In my code i am using the variable PATH_MAX for a buffer size. I had a problem when i was including the library who is supposed to define it #include <limits.h>. When i use this library my IDE doesn't recognize the variable as being define but when I include the library like #include <linux/limits.h> there is no problem and the variable is define. My question is what is the difference between both of them and will it cause problem when I will cross-compile my project ?

Thank you for all answer!


Solution

  • The limits.h header is a standard header that all implementations are required to supply. This contains numerical limits such as INT_MIN and INT_MAX among others. PATH_MAX is not part of this file.

    The linux/limits.h header is specific to Linux. It is here that PATH_MAX is defined.