[cfe-dev] Tracking variable endieness at compile time (C language)

James Dennett via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 13 10:04:27 PST 2017


On Sun, Nov 12, 2017 at 11:45 PM, Nikodemus Siivola via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> A solution requiring no compiler support is to wrap the little endian
> values in a struct.
>
> template<typename T>
> struct little_endian {
>     little_endian(T value) : _value(value) {}
>     T _value;
>     T convert() {
>        // conversion here
>     }
> };
>
>
That requires a lot more compiler support than C gives you ;-)   (The need
for C wasn't explicit in the message body, I think, but it's in the subject
line.)

-- James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171113/6de87c6a/attachment.html>


More information about the cfe-dev mailing list