↧
Answer by chux for Does C have an equivalent of std::less from C++?
Does C offer something with similar functionality which would allow safely comparing arbitrary pointers. No First let us only consider object pointers. Function pointers bring in a whole other set of...
View ArticleAnswer by JL2210 for Does C have an equivalent of std::less from C++?
No. I once tried to find a way around this but I couldn't find anything. Your best bet is probably casting to uintptr_t and hoping the compiler does the right thing.
View ArticleDoes C have an equivalent of std::less from C++?
I was recently answering a question on the undefined behaviour of doing p < q in C when p and q are pointers into different objects/arrays. That got me thinking: C++ has the same (undefined)...
View ArticleAnswer by Peter Cordes for Does C have an equivalent of std::less from C++?
On implementations with a flat memory mode (basically everything), casting to uintptr_t will Just Work.But systems with non-flat memory models do exist, and thinking about them can help explain the...
View ArticleAnswer by supercat for Does C have an equivalent of std::less from C++?
The C Standard explicitly allows implementations to behave "in a documented manner characteristic of the environment" when an action invokes "Undefined Behavior". When the Standard was written, it...
View Article
More Pages to Explore .....