Results 1 to 3 of 3

Thread: endians

  1. #1
    Serf
    Join Date
    Oct 2008
    Location
    germany
    Posts
    2

    Default endians

    hi,

    can somebody tell me if the endian-feature in ver. 0.8 works correctly..

    bool isBig(){
    const int i = 1;
    return !(*(char*)(&i));
    }

    seems a bit of broken to me. The optimizer would make always true of this. Shouldn't it be:
    volatile int i = 1;

    What are the default settings?

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    I use 0.8 for my app novashell and the 'universal binaries' it creates for OSX do correctly detect endianness. (You can test PPC emulation by forcing the app to run through Rosetta)

    So it seems ok with GCC at least.
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Serf
    Join Date
    Oct 2008
    Location
    germany
    Posts
    2

    Default

    thanks Seth,

    I'm currently working on (planning) a kind of "game" with a distributed server network (all the servers have to run on variety of Linux-platforms) and Win/MacOSX clients.

    The ClanLib-Network architecture would make quite a bit of my work easier.

    The question is: Could I rely, that a message I send from one platform, will be correctly read on another one... Something like:

    Client:
    sendMessage(...){
    CL_NetPacket msg;
    msg.output.set_little_endian_mode();
    msg.output.write_int32(some_int);
    [...]
    }

    Server:
    onMessage(...){
    msg.input.set_little_endian_mode();
    some_int = msg.input.read_int32();
    [...]
    }

    Would that work, whatever system the server an client are running on?
    What about streams?

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •