KDE

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • khtml crashes on win32/msvc

    8 answers - 971 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi,
    I've two problems with khtml on win32/msvc:
    1) msvc can't handle structs with boolean bitfields:
    struct InheritedFlags {
    bool _border_collapse : 1 ;
    };
    -needs to be
    struct InheritedFlags {
    unsigned _border_collapse : 1 ;
    };
    2) msvc can't handle structs with enum bitfields (when count(bits) 1):
    - setting a value works fine
    - reading does not work because an enum is defined as a signed int -I get negative values
    the workaround for this is to perform a bitwise and ->
    #ifdef Q_CC_MSVC
    #define KHTML_ENUM_MSVC_FIX(v, t, s) ((t)(v & 1<<(s-1)))
    #else
    #define KHTML_ENUM_MSVC_FIX(v, t, s) t
    #endif
    EUserInput userInput(InheritedFlags it) {
    return KHTML_ENUM_MSVC_FIX(it.f._user_input, EUserInput, 2);
    }
    Is it ok to handle the msvc bugs this way?
    If yes, I would like to check this changes in asap.
    Thx,
    Christian Ehrlicher
  • No.1 | | 1110 bytes | |

    Hi,

    here my unimportant opinion:

    Wednesday 28 February 2007 13:35, Ch.Ehrlicher (AT) gmx (DOT) de wrote:
    Hi,

    I've two problems with khtml on win32/msvc:

    1) msvc can't handle structs with boolean bitfields:

    struct InheritedFlags {

    bool _border_collapse : 1 ;
    };

    -needs to be

    struct InheritedFlags {

    unsigned _border_collapse : 1 ;
    };

    Sounds good IM

    2) msvc can't handle structs with enum bitfields (when count(bits) 1):

    - setting a value works fine
    - reading does not work because an enum is defined as a signed int -I get
    negative values the workaround for this is to perform a bitwise and ->

    #ifdef Q_CC_MSVC
    #define KHTML_ENUM_MSVC_FIX(v, t, s) ((t)(v & 1<<(s-1)))
    #else
    #define KHTML_ENUM_MSVC_FIX(v, t, s) t
    #endif

    EUserInput userInput(InheritedFlags it) {
    return KHTML_ENUM_MSVC_FIX(it.f._user_input, EUserInput, 2);
    }

    This looks a bit ugly.
    Maybe there is a compiler switch where you can changed how enums are handled ?

    Bye
    Alex
  • No.2 | | 1721 bytes | |

    Alexander Neundorf schrieb:
    Hi,

    here my unimportant opinion:

    Wednesday 28 February 2007 13:35, Ch.Ehrlicher (AT) gmx (DOT) de wrote:
    >Hi,
    >>

    >I've two problems with khtml on win32/msvc:
    >>

    >1) msvc can't handle structs with boolean bitfields:
    >>

    >struct InheritedFlags {
    >
    >bool _border_collapse : 1 ;
    >};
    >>

    >-needs to be
    >>

    >struct InheritedFlags {
    >
    >unsigned _border_collapse : 1 ;
    >};


    Sounds good IM

    >2) msvc can't handle structs with enum bitfields (when count(bits) 1):
    >>

    >- setting a value works fine
    >- reading does not work because an enum is defined as a signed int -I get
    >negative values the workaround for this is to perform a bitwise and ->
    >>

    >#ifdef Q_CC_MSVC
    >#define KHTML_ENUM_MSVC_FIX(v, t, s) ((t)(v & 1<<(s-1)))
    >#else
    >#define KHTML_ENUM_MSVC_FIX(v, t, s) t
    >#endif
    >>

    >EUserInput userInput(InheritedFlags it) {
    >return KHTML_ENUM_MSVC_FIX(it.f._user_input, EUserInput, 2);
    >}


    This looks a bit ugly.
    Maybe there is a compiler switch where you can changed how enums are handled ?

    I know that it's ugly, but I could not find an option to make enums
    unsigned. msdn clearly says, that an enum is int or int64 :(

    Christian
  • No.3 | | 189 bytes | |

    Wednesday 28 February 2007, Christian Ehrlicher wrote:
    msdn clearly says, that an enum is int or int64 :(
    Another solution, then, is to never use the most significant bit, right?
  • No.4 | | 581 bytes | |

    David Faure schrieb:
    Wednesday 28 February 2007, Christian Ehrlicher wrote:
    >msdn clearly says, that an enum is int or int64 :(


    Another solution, then, is to never use the most significant bit, right?

    Yes - this could help. I'll try it out :)
    But this maybe increases the struct to more than 64 bits I'll see.

    Christian

    PGP SIGNATURE
    Version: GnuPG v1.4.6 (MingW32)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    KtYFfCqoF8viw2swILcKbkU=
    =gkTo
    PGP SIGNATURE
  • No.5 | | 714 bytes | |

    David Faure schrieb:
    Wednesday 28 February 2007, Christian Ehrlicher wrote:
    >msdn clearly says, that an enum is int or int64 :(


    Another solution, then, is to never use the most significant bit, right?

    , I now tried to extend the two problematic structs , but now I need
    more than 64 bits for RenderStyle::NonInheritedFlags -it breaks the
    operator== for the highest two bits

    But at least kopete does not crash in khtml anymore :)

    Any ideas?
    Christian

    PGP SIGNATURE
    Version: GnuPG v1.4.6 (MingW32)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    bqW0LAbgHf9ThHe5DnbBV/w=
    =tLr+
    PGP SIGNATURE
  • No.6 | | 1032 bytes | |

    Le Vendredi 02 Mars 2007 20:42, Christian Ehrlicher a :
    David Faure schrieb:
    Wednesday 28 February 2007, Christian Ehrlicher wrote:
    >msdn clearly says, that an enum is int or int64 :(
    >

    Another solution, then, is to never use the most significant bit, right?

    , I now tried to extend the two problematic structs , but now I need
    more than 64 bits for RenderStyle::NonInheritedFlags -it breaks the
    operator== for the highest two bits

    But at least kopete does not crash in khtml anymore :)

    Any ideas?

    couldn't you conditionally replace the enum types wherever it matters?

    e.g.
    #ifdef SIGNED_BF_ENUMS
    #define BF_ENUM(a) unsigned int
    #define CAST_BF_ENUM(a,b) static_cast<a>(b)
    #else
    #define BF_ENUM(a) a
    #define CAST_BF_ENUM(a,b) b
    #endif

    and then

    BF_ENUM(EListStyleType) _list_style_type : 6;

    EListStyleType listStyleType() const {
    return CAST_BF_ENUM(EListStyleType, );
    }
  • No.7 | | 220 bytes | |

    couldn't you conditionally replace the enum types wherever it matters?
    oh, and if negative vaules are actually used by msvc, I guess it implies
    manually specifying all enums to begin at zero too
  • No.8 | | 555 bytes | |

    Germain Garand schrieb:
    >couldn't you conditionally replace the enum types wherever it matters?


    oh, and if negative vaules are actually used by msvc, I guess it implies
    manually specifying all enums to begin at zero too

    No, this is imho not needed - enums always start at zero also with msvc

    Christian

    PGP SIGNATURE
    Version: GnuPG v1.4.6 (MingW32)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    BIHvC+6xdSmv2IDsPKvtQ5s=
    =sN3v
    PGP SIGNATURE

Re: khtml crashes on win32/msvc


max 4000 letters.
Your nickname that display:
In order to stop the spam: 4 + 3 =
QUESTION ON "KDE"

EMSDN.COM