On 23/07/2013 06:17, Marvin Humphrey wrote:
Endian helpers are definitely useful. But are they an essential part of the
core Clownfish runtime? JSON parsing is also useful -- is it core to
Clownfish? Isn't Clownfish ambitious enough already?
I could understand if you were making the argument that it's not worth the
effort to move the endian stuff elsewhere, but if you're arguing that it
really belongs where it is, we may have different visions for the scope of the
Clownfish runtime.
I wouldn't say that the endian helpers are essential for Clownfish, but
it is part of my vision that the Clownfish runtime provides some basics
like that.
Regardless, we still don't need to determine endianness with a probe. Here's
a static inline function for determining endianness which the compiler will
optimize away:
I'm not sure whether it is undefined behavior according to various C/C++
standards to write to one member in a union then read a different member, but
this code yielded identical results using gcc and g++ on Linux, and clang in
both C and C++ mode on OS X.
This shouldn't be a problem. I'm more worried that some compilers might
not optimize the probe away.
Let's go back to your list of platform-specific code the runtime currently
depends on:
Even if we find ways to detect every platform feature via macros or at
runtime, what's wrong with the feature tests that we already have? They
look more robust to me.
Nick