T
ThazKool
I want to see if this code works the way it should on a Big-Endian
system. Also if anyone has any ideas on how determine this at
compile-time so that I use the right decoding or encoding functions, I
would greatly appreciate the help.
Thanks,
Ché
#include <iostream>
int main( int argc, char* argv[] )
{
// Default system to little endian
bool isLittleEndian = true;
// Check whether this platform is big-endian or little endian
wchar_t a = L'a';
unsigned char* testChar = reinterpret_cast<unsigned char*>( &a );
// Big Endian should display nothing on output here
std::cout << (unsigned char*) testChar << std::endl;
if( testChar == 0 )
{
isLittleEndian = false;
// Big Endian should display '"Big Endian Success" here
std::cout << "Big Endian Success" << std::endl;
return 0;
}
system. Also if anyone has any ideas on how determine this at
compile-time so that I use the right decoding or encoding functions, I
would greatly appreciate the help.
Thanks,
Ché
#include <iostream>
int main( int argc, char* argv[] )
{
// Default system to little endian
bool isLittleEndian = true;
// Check whether this platform is big-endian or little endian
wchar_t a = L'a';
unsigned char* testChar = reinterpret_cast<unsigned char*>( &a );
// Big Endian should display nothing on output here
std::cout << (unsigned char*) testChar << std::endl;
if( testChar == 0 )
{
isLittleEndian = false;
// Big Endian should display '"Big Endian Success" here
std::cout << "Big Endian Success" << std::endl;
return 0;
}