Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > template and dynamic decisions

Thread Tools

template and dynamic decisions

Gianni Mariani
Posts: n/a
Gianni Mariani wrote:
> Ron Natalie wrote:


> Anyhow - I just remembered I have a g++ - solaris cross compiler loaded
> on my machine (which is big endian) and the it actually does the
> (TM)right thing.

The statement above is blatently wrong and even incorrect.

A g++ cross compiler does in fact NOT do the (TM)right thing.

Reply With Quote
Samuel Barber
Posts: n/a
Jocke P <(E-Mail Removed)> wrote in message news:<bifo0s$bbe$(E-Mail Removed)>...
> struct MachineEndian
> {
> enum { is_big = ('B' == (char)(int)'Big ') };
> };
> - and it "works" (ie is 0) on my little-endian machine.

Why do you call that working? If we assume for the sake of argument
(NOT TRUE!) that '1234' depends on endianness, then it should work
like this:

little endian: '1234' = 0x34333231
big endian: '1234' = 0x31323334

So your test failed.

If that isn't clear, consider:

#include <stdio.h>

int main(void)
char a[5]="1234";

int i = *(int*)a;

int j = '1234';

// does i == j ?

printf("i=0x%x, j=0x%x", i, j);

return 0;

By the way, Intel assemblers use the "big endian" definition of

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Decisions, Decisions.... Max Burke NZ Computing 25 09-24-2006 05:58 AM
Decisions, decisions... Waterspider Digital Photography 8 12-28-2005 09:48 PM
Decisions Decisions Larry Digital Photography 4 06-28-2005 03:41 PM
File or assembly Crystal.Decisions.Web not found ASP .Net 0 11-11-2004 01:31 PM
Architecture Decisions Regarding Common DB Access, Remoting, and Performance JTS ASP .Net 0 01-22-2004 07:51 AM