Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/sock/udp: designated initializer, C++ compatibility #18035

Merged
merged 1 commit into from
Apr 29, 2022

Conversation

laurin
Copy link
Contributor

@laurin laurin commented Apr 28, 2022

Contribution description

Compiling RIOT for native while including sys/include/net/sock/udp.h from a C++ file will result in this error:

<RIOTBASE>/sys/include/net/sock/udp.h: In function ‘ssize_t sock_udp_send_aux(sock_udp_t*, const void*, size_t, const sock_udp_ep_t*, sock_udp_aux_tx_t*)’:
<RIOTBASE>/sys/include/net/sock/udp.h:686:9: error: C++ designated initializers only available with ‘-std=c++2a’ or ‘-std=gnu++2a’ [-Werror=pedantic]
  686 |         .iol_base = (void *)data,
      |         ^
<RIOTBASE>/sys/include/net/sock/udp.h:687:9: error: C++ designated initializers only available with ‘-std=c++2a’ or ‘-std=gnu++2a’ [-Werror=pedantic]
  687 |         .iol_len  = len,
      |         ^
<RIOTBASE>/sys/include/net/sock/udp.h:688:5: error: missing initializer for member ‘iolist::iol_next’ [-Werror=missing-field-initializers]
  688 |     };
      |     ^

Like jenswet said in #17636

I know the code change makes the code less readable. If you have better ideas on fixing it, I am happy for suggestions. We could also think about removing the ISO C++ requirement from the compiler flags for native.

Testing procedure

Green Murdock

@laurin laurin requested a review from maribu as a code owner April 28, 2022 21:55
@github-actions github-actions bot added Area: network Area: Networking Area: sys Area: System labels Apr 28, 2022
@laurin laurin changed the title /net/sock/udp: designated iolist_t intializer net/sock/udp: designated intializer, C++ compatibility Apr 28, 2022
@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Apr 28, 2022
@maribu maribu enabled auto-merge April 28, 2022 23:45
@maribu
Copy link
Member

maribu commented Apr 28, 2022

Thanks for addressing this!

At least with the upcoming C++ standard designated initializes can be used without relying on non-standard compiler extensions :)

@maribu maribu merged commit 7eaa437 into RIOT-OS:master Apr 29, 2022
@laurin laurin deleted the net-sock-udp-designated-initializers branch April 29, 2022 12:24
@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
@benpicco benpicco changed the title net/sock/udp: designated intializer, C++ compatibility net/sock/udp: designated initializer, C++ compatibility Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants