Skip to content

Commit 40cc809

Browse files
authored
gh-117549: Don't use designated initializers in headers (#118580)
The designated initializer syntax in static inline functions in pycore_backoff.h causes problems for C++ or MSVC users who aren't yet using C++20. While internal, pycore_backoff.h is included (indirectly, via pycore_code.h) by some key 3rd party software that does so for speed.
1 parent 44f6791 commit 40cc809

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Include/internal/pycore_backoff.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,18 @@ make_backoff_counter(uint16_t value, uint16_t backoff)
4444
{
4545
assert(backoff <= 15);
4646
assert(value <= 0xFFF);
47-
return (_Py_BackoffCounter){.backoff = backoff, .value = value};
47+
_Py_BackoffCounter result;
48+
result.value = value;
49+
result.backoff = backoff;
50+
return result;
4851
}
4952

5053
static inline _Py_BackoffCounter
5154
forge_backoff_counter(uint16_t counter)
5255
{
53-
return (_Py_BackoffCounter){.as_counter = counter};
56+
_Py_BackoffCounter result;
57+
result.as_counter = counter;
58+
return result;
5459
}
5560

5661
static inline _Py_BackoffCounter
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Don't use designated initializer syntax in inline functions in internal
2+
headers. They cause problems for C++ or MSVC users who aren't yet using the
3+
latest C++ standard (C++20). While internal, pycore_backoff.h, is included
4+
(indirectly, via pycore_code.h) by some key 3rd party software that does so
5+
for speed.

0 commit comments

Comments
 (0)