#228 SELFLAG in oleacc.h

closed-fixed
2002-12-13
2002-12-11
No

Hi,

SELFLAG_* are defined as macros in oleacc.h but according to
MSDN they are supposed to be enum values:
http://msdn.microsoft.com/library/en-us/msaa/msaaccrf_3zxj.asp

typedef enum tagSELFLAG
{
SELFLAG_NONE = 0,
SELFLAG_TAKEFOCUS = 1,
SELFLAG_TAKESELECTION = 2,
SELFLAG_EXTENDSELECTION = 4,
SELFLAG_ADDSELECTION = 8,
SELFLAG_REMOVESELECTION = 16
} SELFLAG;

Discussion

  • Danny Smith

    Danny Smith - 2002-12-12

    Logged In: YES
    user_id=11494

    OK, but won't that mean also changing the declaration
    of the methods that use these flags as arguments?

    Danny

     
  • Dimitri Papadopoulos

    • labels: 103945 --> 104599
     
  • Dimitri Papadopoulos

    Logged In: YES
    user_id=300680

    I think enum's are automatically cast to int's, so you shouldn't have to
    modify function signatures.

     
  • Danny Smith

    Danny Smith - 2002-12-13

    Logged In: YES
    user_id=11494

    Thanks.

    Committed to CVS

    Danny

     
  • Danny Smith

    Danny Smith - 2002-12-13
    • status: open --> closed-fixed
     
  • Luke Dunstan

    Luke Dunstan - 2002-12-13

    Logged In: YES
    user_id=30442

    I'm not sure that this is correct. Enumerated types are only
    interchangeable with integers in C, not C++. The MSDN
    documentation showing an enum might just be for conceptual
    reasons, because MSVC6 headers use #define like Mingw
    did. This might have changed in a later PSDK but I doubt it.
    Anyway, IMHO enumerations shouldn't be used for values
    that are bitwise ORed together.

     
  • Luke Dunstan

    Luke Dunstan - 2002-12-13
    • labels: 104599 --> w32api (deprecated use WSL)
     
  • Dimitri Papadopoulos

    Logged In: YES
    user_id=300680

    OK, I must say I'm not sure about this one. It could be that some compilers
    cannot cast enum's to integer's. Also if the MSDN is showing an enum just
    for conceptual reasons and the vendors actually use #define, then I agree
    #define should be used.

    As for using enumerations for values that are bitwise ORed, it does work as
    far as I know. I agree it's not clean, but at least it pollutes the global
    namespace less than a macro.

     
  • Danny Smith

    Danny Smith - 2002-12-13

    Logged In: YES
    user_id=11494

    G++ does cast enums automatically. I commited after
    looking at the authoritative public documentation for
    SELFLAGS_* cited by Dimitri and testing the enum vs
    long signature issue with following.

    The code code compiles without warning with G++ -
    Wall -pedantic

    /* enum.cpp */
    typedef enum _colour
    {
    red = 0,
    blue =1,
    yellow= 2
    } colour;

    long foo (long a)
    {
    return a;
    }

    int main()
    {
    colour z = red;
    return foo(z);
    }

    Danny

     
  • Luke Dunstan

    Luke Dunstan - 2002-12-13

    Logged In: YES
    user_id=30442

    okay, I was mistaken :)

    I understand the importance of using public documentation for
    writing the headers.

     
  • Dimitri Papadopoulos

    Logged In: YES
    user_id=300680

    I had a friend check the latest SDK and it seems Microsoft still use enum's
    instead of macro definitions:

    #define SELFLAG_TAKEFOCUS ( 0x1 )

    #define SELFLAG_TAKESELECTION ( 0x2 )

    ...

    I'm not sure it was a good idea to suggest using enum's... Sorry.

     
  • Dimitri Papadopoulos

    Logged In: YES
    user_id=300680

    > it seems Microsoft still use enum's instead of macro definitions:

    Of course I'm wrong again, sorry. Please read instead:
    it seems Microsoft still use macro definitions instead of enum's:

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks