summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-09-29 20:04:02 +0000
committerThomas Heller <theller@ctypes.org>2008-09-29 20:04:02 +0000
commita702fd537db5c38838ccbb8188253feeb73dea69 (patch)
treebffd10fb3039acd1fcf96a8d81583970a73855e3
parent70f1192dfcd2fea86dde9490b57d6fef919ceba1 (diff)
downloadcpython-git-a702fd537db5c38838ccbb8188253feeb73dea69.tar.gz
Fix issue #3547 for MingW, update comments (backport from trunk).
-rw-r--r--Lib/ctypes/test/test_bitfields.py5
-rw-r--r--Modules/_ctypes/cfield.c8
2 files changed, 8 insertions, 5 deletions
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py
index ddd753ea09..96cd7c6442 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/ctypes/test/test_bitfields.py
@@ -223,8 +223,9 @@ class BitFieldTest(unittest.TestCase):
("d", c_short, 4),
("e", c_short, 4),
("f", c_int, 24)]
- # MS compilers do NOT combine c_short and c_int into
- # one field, gcc does.
+ # MSVC does NOT combine c_short and c_int into one field, GCC
+ # does (unless GCC is run with '-mms-bitfields' which
+ # produces code compatible with MSVC).
if os.name in ("nt", "ce"):
self.failUnlessEqual(sizeof(X), sizeof(c_int) * 4)
else:
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index adf85971e4..f5b3c40cbc 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -65,10 +65,12 @@ CField_FromDesc(PyObject *desc, int index,
}
if (bitsize /* this is a bitfield request */
&& *pfield_size /* we have a bitfield open */
-#if defined(MS_WIN32) && !defined(__MINGW32__)
- && dict->size * 8 == *pfield_size /* MSVC */
+#ifdef MS_WIN32
+ /* MSVC, GCC with -mms-bitfields */
+ && dict->size * 8 == *pfield_size
#else
- && dict->size * 8 <= *pfield_size /* GCC, MINGW */
+ /* GCC */
+ && dict->size * 8 <= *pfield_size
#endif
&& (*pbitofs + bitsize) <= *pfield_size) {
/* continue bit field */