I know the way of non meta programing to decide a PC is little endian or not.
eg:
#include <iostream>
#include <stdint.h>
union A {
uint16_t v;
char c[2];
};
int main(void) {
A a;
a.v = 0x0102;
std::cout << (a.c[0] == 0x01 ? "big endian" : "little endian") << std::endl;
return 0;
}
But, it's expensive in run time, isn't it?
So, is there a way to decide a PC is little endian or not by meta programing?
Thanks!