Skip to content

Commit f139d84

Browse files
authored
gh-116869: Fix redefinition of the _PyOptimizerObject type (#116963)
Defining a type twice is a C11 feature and so makes the C API incompatible with C99. Fix the issue by only defining the type once. Example of warning (treated as an error): In file included from Include/Python.h:122: Include/cpython/optimizer.h:77:3: error: redefinition of typedef '_PyOptimizerObject' is a C11 feature [-Werror,-Wtypedef-redefinition] } _PyOptimizerObject; ^ build/Include/cpython/optimizer.h:60:35: note: previous definition is here typedef struct _PyOptimizerObject _PyOptimizerObject; ^
1 parent 1d95451 commit f139d84

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Include/cpython/optimizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ typedef int (*optimize_func)(
6565
_Py_CODEUNIT *instr, _PyExecutorObject **exec_ptr,
6666
int curr_stackentries);
6767

68-
typedef struct _PyOptimizerObject {
68+
struct _PyOptimizerObject {
6969
PyObject_HEAD
7070
optimize_func optimize;
7171
/* These thresholds are treated as signed so do not exceed INT16_MAX
@@ -74,7 +74,7 @@ typedef struct _PyOptimizerObject {
7474
uint16_t side_threshold;
7575
uint16_t backedge_threshold;
7676
/* Data needed by the optimizer goes here, but is opaque to the VM */
77-
} _PyOptimizerObject;
77+
};
7878

7979
/** Test support **/
8080
typedef struct {

0 commit comments

Comments
 (0)