On Wed, Nov 8, 2017 at 1:07 AM, Brian Paul <bri...@vmware.com> wrote:
> Use the proper enum types for various variables.  Makes life in gdb
> a little nicer.  Note that the size of enum bitfields must be one
> larger so the high bit is always zero (for MSVC).

You *could* also do something like this on MSVC to get unsigned enum
values, thus not needing the extra bit:

---8<---
#include <stdio.h>

#ifdef _MSC_VER
#define FORCE_UNSIGNED : unsigned
#else
#define FORCE_UNSIGNED
#endif

enum Foo FORCE_UNSIGNED {
   FOO_A = 1,
   FOO_B = 255
};

struct Bar {
   Foo foo : 8;
};

int main()
{
   Bar foo;
   foo.foo = FOO_B;
   printf("%d\n", foo.foo);
   return 0;
}
---8<---

This outputs 255 on MSVC.

It's not beautiful, though.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to