mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	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;
                                    ^
			
			
This commit is contained in:
		
							parent
							
								
									1d95451be1
								
							
						
					
					
						commit
						f139d840fb
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -65,7 +65,7 @@ typedef int (*optimize_func)(
 | 
				
			||||||
    _Py_CODEUNIT *instr, _PyExecutorObject **exec_ptr,
 | 
					    _Py_CODEUNIT *instr, _PyExecutorObject **exec_ptr,
 | 
				
			||||||
    int curr_stackentries);
 | 
					    int curr_stackentries);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct _PyOptimizerObject {
 | 
					struct _PyOptimizerObject {
 | 
				
			||||||
    PyObject_HEAD
 | 
					    PyObject_HEAD
 | 
				
			||||||
    optimize_func optimize;
 | 
					    optimize_func optimize;
 | 
				
			||||||
    /* These thresholds are treated as signed so do not exceed INT16_MAX
 | 
					    /* These thresholds are treated as signed so do not exceed INT16_MAX
 | 
				
			||||||
| 
						 | 
					@ -74,7 +74,7 @@ typedef struct _PyOptimizerObject {
 | 
				
			||||||
    uint16_t side_threshold;
 | 
					    uint16_t side_threshold;
 | 
				
			||||||
    uint16_t backedge_threshold;
 | 
					    uint16_t backedge_threshold;
 | 
				
			||||||
    /* Data needed by the optimizer goes here, but is opaque to the VM */
 | 
					    /* Data needed by the optimizer goes here, but is opaque to the VM */
 | 
				
			||||||
} _PyOptimizerObject;
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Test support **/
 | 
					/** Test support **/
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue