Skip to content

Commit

Permalink
Include <stdbool.h> & use bool rather than _Bool
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou committed Dec 9, 2024
1 parent 6e8a4de commit 870a038
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Modules/_ctypes/cfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "pycore_bitutils.h" // _Py_bswap32()
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include <stdbool.h> // bool

#include <ffi.h>
#include "ctypes.h"
Expand Down Expand Up @@ -522,7 +523,7 @@ v_get(void *ptr, Py_ssize_t size)
return PyBool_FromLong((long)*(short int *)ptr);
}

/* bool ('?'): _Bool */
/* bool ('?'): bool (i.e. _Bool) */
static PyObject *
bool_set(void *ptr, PyObject *value, Py_ssize_t size)
{
Expand All @@ -531,10 +532,10 @@ bool_set(void *ptr, PyObject *value, Py_ssize_t size)
case -1:
return NULL;
case 0:
*(_Bool *)ptr = 0;
*(bool *)ptr = 0;
_RET(value);
default:
*(_Bool *)ptr = 1;
*(bool *)ptr = 1;
_RET(value);
}
}
Expand All @@ -543,7 +544,7 @@ static PyObject *
bool_get(void *ptr, Py_ssize_t size)
{
assert(NUM_BITS(size) || (size == sizeof(bool)));
return PyBool_FromLong((long)*(_Bool *)ptr);
return PyBool_FromLong((long)*(bool *)ptr);
}

/* g: long double */
Expand Down

0 comments on commit 870a038

Please sign in to comment.