Comments (10)
had that problem too, fixed it by adding those two includes to imgui.cpp
from imgui.
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.
from imgui.
Sure, (compiled with clang)
imgui.cpp:912:27: error: use of undeclared identifier 'INT_MAX' FocusIdxRequestCurrent = INT_MAX;
imgui.cpp:2843:31: error: unknown type name 'intptr_t'; did you mean '__intptr_t'? const void* ptr_id = (void*)(intptr_t)int_id;
first one solved by including limits.h, second one by including stdint.h
from imgui.
Thanks, it is fixed in trunk now.
from imgui.
Just had a report that limits.h doesn't exist on OSX.
Could you tell me if include stdint.h only fix the build on your setup? (wikipedia implies that stdint.h is a superset of limits.h). Thanks.
from imgui.
Removing limits.h , still brings INT_MAX not found error
However there is INT32_MAX defined inside stdint.h, I guess you could use that one.
from imgui.
I removed the need for INT_MAX to simplify anyway, it was only used as a marker for a value being "unset".
from imgui.
I couldn't miss the opportunity of commenting issue #1 ;-)
Some time ago I've spotted some smart code to get Min and Max Value of any integer type from the Cap'n'Proto source code without using limits.h.
Do not worry about the constexpr thing, it can be disabled entirely (and it is for MSVC by default already).
#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
{
}
from imgui.
Welcome to issue 1.
Not including that sort of code in ImGui! :)
I sort of see why it may be essential to Cap'n'Proto which needs reliable data on every type, we just want INT_MAX. Worst case we can add an ifdef include thing to cope with a few bad cases. I have readded <limits.h>
from imgui.cpp to see if anyone reacts since I don't have a proper recorded reason for not including it.
from imgui.
That's fine, I was just looking for a realistic excuse to be featured in issue 1 😆
from imgui.
Related Issues (20)
- Rendering vertices with the D3DPT_LINESTRIP type. HOT 1
- Can't access some stuff from imgui.h HOT 1
- Suggestion: Consider Adding Title Bar Text to Popups HOT 2
- SDL3 Multi-Viewports not creating windows when main window is hidden
- Recommended way to expand / collapse tree nodes with keyboard shortcuts? HOT 3
- VuIkan: invalid Dynamic Rendering functions from the Instance-level loader HOT 3
- Text Bottom Padding Bug HOT 1
- Power savings & hardware usage HOT 3
- Add RGFW backend implementation HOT 2
- Text wrapping: how does it work? HOT 1
- ImDrawList rects aren't perfect HOT 6
- Running ImGui app on Arm Processor (Allwinner H3 with mali 400 -> orangepi one) HOT 1
- Can no longer use ctrl shortcuts in InputText's as of v1.90.6 HOT 4
- ImGui::BeginTooltip() should allow specifying override HOT 4
- No Hover Flags in ImGui::IsAnyItemHovered() HOT 4
- Keeping combo open after clicking selectable
- Stretch table to window scrollable size
- TitleBarRect does not contain FramePadding. This will cause the window to not move correctly after ConfigWindowsMoveFromTitleBarOnly is enabled.
- Small window flickering when move out the edge of main window. HOT 1
- Can't select only 1 input when inputs are slightly close to each other HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.