Click here to Skip to main content
15,919,121 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionConnection Error Pin
Programm3r13-Sep-07 20:37
Programm3r13-Sep-07 20:37 
AnswerRe: Connection Error Pin
p_13-Sep-07 23:35
p_13-Sep-07 23:35 
QuestionHow to get the byte order of a computer? Pin
kcynic13-Sep-07 20:01
kcynic13-Sep-07 20:01 
AnswerRe: How to get the byte order of a computer? Pin
Azteke13-Sep-07 20:06
Azteke13-Sep-07 20:06 
GeneralRe: How to get the byte order of a computer? Pin
kcynic13-Sep-07 22:23
kcynic13-Sep-07 22:23 
GeneralRe: How to get the byte order of a computer? Pin
Maxwell Chen13-Sep-07 22:32
Maxwell Chen13-Sep-07 22:32 
GeneralRe: How to get the byte order of a computer? Pin
David Crow14-Sep-07 3:22
David Crow14-Sep-07 3:22 
AnswerRe: How to get the byte order of a computer? [modified] Pin
kakan13-Sep-07 20:48
professionalkakan13-Sep-07 20:48 
One way to do it. I'm not sure if it works on 64-bits CPU's though.
Remark (before I get flamed): Yes, it is old C code.

Detection of Little- and Big-endian:
bool bIsLittleEndian = false;
unsigned int test = 0x12345678;
unsigned char firstByte = *(unsigned char *) &test;

if(firstByte == 0x78) bIsLittleEndian = true;


Detection of Little-, Middle and Big-endian:
enum {LITTLE_ENDIAN, MIDDLE_ENDIAN, BIG_ENDIAN};

int endian;
unsigned int test = 0x12345678;
unsigned char firstByte = *(unsigned char *) &test;

if(firstByte == 0x78) endian = LITTLE_ENDIAN;
else if(firstByte == 0x34) endian = MIDDLE_ENDIAN;
else endian = BIG_ENDIAN;


-- modified at 5:38 Friday 14th September, 2007
Maxwell Chen made me aware there are such a thing as Middle-endian, so I made another sample. (Middle-endian is appearantly used in some PDAs and mobile phones that is using CPU's with ARM architecture.)



Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

GeneralRe: How to get the byte order of a computer? Pin
Maxwell Chen13-Sep-07 22:30
Maxwell Chen13-Sep-07 22:30 
GeneralRe: How to get the byte order of a computer? Pin
kakan13-Sep-07 23:28
professionalkakan13-Sep-07 23:28 
GeneralRe: How to get the byte order of a computer? Pin
Azteke14-Sep-07 18:10
Azteke14-Sep-07 18:10 
QuestionReading microphone input Pin
Azteke13-Sep-07 19:35
Azteke13-Sep-07 19:35 
AnswerRe: Reading microphone input Pin
Russell'13-Sep-07 22:04
Russell'13-Sep-07 22:04 
GeneralRe: Reading microphone input Pin
Azteke14-Sep-07 18:12
Azteke14-Sep-07 18:12 
GeneralRe: Reading microphone input Pin
Russell'14-Sep-07 22:25
Russell'14-Sep-07 22:25 
QuestionReg. Structure variable [modified] Pin
rajaratk13-Sep-07 19:22
rajaratk13-Sep-07 19:22 
AnswerRe: Reg. Structure variable Pin
Nishad S13-Sep-07 20:23
Nishad S13-Sep-07 20:23 
GeneralRe: Reg. Structure variable Pin
rajaratk13-Sep-07 22:47
rajaratk13-Sep-07 22:47 
GeneralRe: Reg. Structure variable Pin
Nishad S14-Sep-07 1:44
Nishad S14-Sep-07 1:44 
QuestionTab Order Pin
msr_codeproject13-Sep-07 17:10
msr_codeproject13-Sep-07 17:10 
AnswerRe: Tab Order Pin
Mark Salsbery13-Sep-07 18:07
Mark Salsbery13-Sep-07 18:07 
AnswerRe: Tab Order Pin
chandu00413-Sep-07 19:39
chandu00413-Sep-07 19:39 
GeneralRe: Tab Order Pin
Nishad S13-Sep-07 20:17
Nishad S13-Sep-07 20:17 
QuestionUpgrading old MFC look to .NET look Pin
Mojoturner13-Sep-07 16:42
Mojoturner13-Sep-07 16:42 
AnswerRe: Upgrading old MFC look to .NET look Pin
sps-itsec4613-Sep-07 22:21
sps-itsec4613-Sep-07 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.