-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Missing includes #1
Comments
had that problem too, fixed it by adding those two includes to imgui.cpp |
Thanks! Shouldn't either limits.h or stdint.h be enough? Is the error you were getting the lack of INT_MAX only? Trying to be very explicit and document why such and such are included in the code. If you could paste the compilation error it would be great. |
Sure, (compiled with clang)
first one solved by including limits.h, second one by including stdint.h |
Thanks, it is fixed in trunk now. |
Just had a report that limits.h doesn't exist on OSX. |
Removing limits.h , still brings INT_MAX not found error |
I removed the need for INT_MAX to simplify anyway, it was only used as a marker for a value being "unset". |
…missing limits.h was erroneous (#1, yes, issue ONE!)
I couldn't miss the opportunity of commenting issue #1 ;-) #if _MSC_VER
#define KJ_CONSTEXPR(...) __VA_ARGS__
#define RR_CONSTEXPR(...) __VA_ARGS__
// Use in cases where MSVC barfs on constexpr. A replacement keyword (e.g. "const") can be
// provided, or just leave blank to remove the keyword entirely.
//
// TODO(msvc): Remove this hack once MSVC fully supports constexpr.
#else // _MSC_VER
#define KJ_CONSTEXPR(...) constexpr
#define RR_CONSTEXPR(...) constexpr
#endif
class MaxValue_ {
private:
template <typename T>
inline KJ_CONSTEXPR() T maxSigned() const {
return (1ull << (sizeof(T) * 8 - 1)) - 1;
}
template <typename T>
inline KJ_CONSTEXPR() T maxUnsigned() const {
return (T) ~static_cast<T>(0u);
}
public:
#define _kJ_HANDLE_TYPE(T) \
inline KJ_CONSTEXPR() operator signed T() const { return MaxValue_::maxSigned < signed T>(); } \
inline KJ_CONSTEXPR() operator unsigned T() const { return MaxValue_::maxUnsigned<unsigned T>(); }
_kJ_HANDLE_TYPE(char)
_kJ_HANDLE_TYPE(short)
_kJ_HANDLE_TYPE(int)
_kJ_HANDLE_TYPE(long)
_kJ_HANDLE_TYPE(long long)
#undef _kJ_HANDLE_TYPE
inline KJ_CONSTEXPR() operator char() const {
// `char` is different from both `signed char` and `unsigned char`, and may be signed or
// unsigned on different platforms. Ugh.
return char(-1) < 0 ? MaxValue_::maxSigned<char>()
: MaxValue_::maxUnsigned<char>();
}
};
class MinValue_ {
private:
template <typename T>
inline KJ_CONSTEXPR() T minSigned() const {
return 1ull << (sizeof(T) * 8 - 1);
}
template <typename T>
inline KJ_CONSTEXPR() T minUnsigned() const {
return 0u;
}
public:
#define _kJ_HANDLE_TYPE(T) \
inline KJ_CONSTEXPR() operator signed T() const { return MinValue_::minSigned < signed T>(); } \
inline KJ_CONSTEXPR() operator unsigned T() const { return MinValue_::minUnsigned<unsigned T>(); }
_kJ_HANDLE_TYPE(char)
_kJ_HANDLE_TYPE(short)
_kJ_HANDLE_TYPE(int)
_kJ_HANDLE_TYPE(long)
_kJ_HANDLE_TYPE(long long)
#undef _kJ_HANDLE_TYPE
inline KJ_CONSTEXPR() operator char() const {
// `char` is different from both `signed char` and `unsigned char`, and may be signed or
// unsigned on different platforms. Ugh.
return char(-1) < 0 ? MinValue_::minSigned<char>()
: MinValue_::minUnsigned<char>();
}
};
static KJ_CONSTEXPR(const) MaxValue_ maxValue = MaxValue_();
// A special constant which, when cast to an integer type, takes on the maximum possible value of
// that type. This is useful to use as e.g. a parameter to a function because it will be robust
// in the face of changes to the parameter's type.
//
// `char` is not supported, but `signed char` and `unsigned char` are.
static KJ_CONSTEXPR(const) MinValue_ minValue = MinValue_();
// A special constant which, when cast to an integer type, takes on the minimum possible value
// of that type. This is useful to use as e.g. a parameter to a function because it will be robust
// in the face of changes to the parameter's type.
//
// `char` is not supported, but `signed char` and `unsigned char` are.
#undef KJ_CONSTEXPR
the way you use it is unsigned int myVariable;
//... myVariable gets assigned somewhere....
if(myVariable > (int)maxValue) // THIS equals myVariable > INT_MAX
{
} |
Welcome to issue 1. |
That's fine, I was just looking for a realistic excuse to be featured in issue 1 😆 |
When compiling with gcc 4.6 in Linux, two needed includes are missing from imgui.cpp:
limits.h
stdint.h
The text was updated successfully, but these errors were encountered: