Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
76 user(s) are online (66 user(s) are browsing Forums)

Members: 0
Guests: 76

more...

Support us!

Headlines

Report message:*
 

signed char became unsigned ?

Subject: signed char became unsigned ?
by kas1e on 2021/1/21 19:42:33

@All

Have some theoretical question.

I do work on some port of a game, which is C++ and which have such a class:

class Door : public Object
{
    public :
        ...
balbalba...

    private :

        ...
balbalba...

        
char _direction;

        ...
balbalba...

};



Now, in the code of the game, depending on the needs, we have set _direction to be 1 or -1. Like this:

void Door::setDirection(core::vector3df ref)
{
    if (
_doorType == DT_ROTATE_X)
    {
        if (
ref._rotateCenter->getPosition().Z_direction 1;
        else 
_direction = -1;
    }
    else if (
_doorType == DT_ROTATE_Z)
    {
        if (
ref._rotateCenter->getPosition().X_direction = -1;
        else 
_direction 1;
    }
}


And when I build it for win32 and when puts prints with %d in relevant parts, it prints 1 or -1 when should.

But when I do the same on amigaos4, it prints then 1 and 255 instead of 1 and -1 (i.e. -1 became 255).

I.e. exactly the same code line per line. Just 2 binaries, one for aos4 and one for win32.

I feel it's something trivial, just can't get what. Does it look like signed char become unsigned? Maybe I need specially specify that this is signed? Or maybe some flag to GCC need to be passed, or it just bad code-practice somewhere?

Maybe in win32 pure "char" mean "signed char", but on amigaos4 pure "char" mean "unsigned char" ?:)


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project