diff --git a/src/lib/parameters/templates/px4_parameters.hpp.jinja b/src/lib/parameters/templates/px4_parameters.hpp.jinja index c215552185..ad2ed9be4d 100644 --- a/src/lib/parameters/templates/px4_parameters.hpp.jinja +++ b/src/lib/parameters/templates/px4_parameters.hpp.jinja @@ -2,10 +2,13 @@ #include // NAN -#include #include #include +#if defined(_MSC_VER) && !defined(__clang__) +# include +#endif + // DO NOT EDIT // This file is autogenerated from parameters.xml @@ -39,10 +42,12 @@ static constexpr param_type_t parameters_type[] = { {%- endfor -%} }; -{# Use std::array so that an empty list (size 0) is well-formed on all - compilers. A C-style "T arr[] = {}" is a GCC/Clang extension; MSVC - rejects it with C2466 ("cannot allocate an array of constant size 0"). - std::array is standard and supports range-for. #} +{# MSVC rejects "T arr[] = {}" with C2466 ("cannot allocate an array of + constant size 0"). std::array is standard, but NuttX libcxx does + not ship . Use std::array on MSVC only and keep the GCC/Clang + extension form everywhere else. Range-for in parameters_common.cpp works + on both. #} +#if defined(_MSC_VER) && !defined(__clang__) static constexpr std::array parameters_volatile = { { {% for param in volatile_params %} params::{{ param.attrib["name"] }}, @@ -54,6 +59,19 @@ static constexpr std::array parameter params::{{ param_name }}, {% endfor %} } }; +#else +static constexpr params parameters_volatile[] = { +{% for param in volatile_params %} + params::{{ param.attrib["name"] }}, +{% endfor %} +}; + +static constexpr params parameters_readonly[] = { +{% for param_name in readonly_param_names %} + params::{{ param_name }}, +{% endfor %} +}; +#endif } // namespace px4