Skip to content

Commit dcedf71

Browse files
committed
pystark windows compilation fix
1 parent 2dc6516 commit dcedf71

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

pystark/cpp/nanobind_stark_include_all.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ inline nb::object create_named_tuple(const std::string& typeName, const std::vec
162162
nb::object collections = nb::module_::import_("collections");
163163
nb::object namedtuple = collections.attr("namedtuple");
164164

165-
// Create a Python list for field names.
166-
// Note: the local variable is named field_list (not fields) to avoid
167-
// potential conflicts with MSVC's name lookup inside Windows SDK headers.
168-
nb::list field_list;
169-
for (const auto& field_name : fieldNames) {
170-
field_list.append(field_name);
165+
// collections.namedtuple accepts field names as a whitespace-separated string,
166+
// which avoids any nb::list / nb::tuple construction that MSVC struggles with.
167+
std::string fields_str;
168+
for (size_t i = 0; i < fieldNames.size(); ++i) {
169+
if (i > 0) fields_str += ' ';
170+
fields_str += fieldNames[i];
171171
}
172-
nb::object tuple_type = namedtuple(typeName.c_str(), field_list);
172+
nb::object tuple_type = namedtuple(typeName.c_str(), fields_str.c_str());
173173

174174
// Use PyObject_Call to unpack `values` as positional args (*values in Python).
175175
// This is explicit and sidesteps MSVC template-resolution issues with

0 commit comments

Comments
 (0)