Proper C/C++ struct initialization.

This commit is contained in:
Jean-Francois Simon committed 2022-11-16 16:19:50 +01:00
1 parent aeab3ef7ac
commit 7ba68dd20d
2 files changed
+11 -6

No files matched your search

+10 -6
View File
@@ -179,18 +179,22 @@ static void test_http_fetch(void) {
mg_mgr_init(&mgr); // Initialise event manager
// MIP driver
struct mip_driver driver;
{
// Zero init fields required (C/C++ style diverge)
#ifndef __cplusplus
struct mip_driver driver = {.tx = tap_tx, .up = tap_up, .rx = tap_rx};
struct mip_if mif = {.use_dhcp = true, .driver = &driver, .driver_data = &fd};
#else
struct mip_driver driver {};
driver.tx = tap_tx;
driver.up = tap_up;
driver.rx = tap_rx;
}
struct mip_if mif;
{
struct mip_if mif {};
mif.use_dhcp = true;
mif.driver = &driver;
mif.driver_data = &fd;
}
#endif
sscanf(mac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &mif.mac[0], &mif.mac[1], &mif.mac[2],
&mif.mac[3], &mif.mac[4], &mif.mac[5]);