Skip to content

Fix C++11 build error w/ u-blox EVK-ODIN-W2 #4251

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

Merged
merged 1 commit into from
May 2, 2017
Merged

Fix C++11 build error w/ u-blox EVK-ODIN-W2 #4251

merged 1 commit into from
May 2, 2017

Conversation

adamgreen
Copy link
Contributor

When attempting to perform a test build of various mbed-os targets with
GCC configured to build -std=gnu++11, all of the targets built
successfully except for this one. It gave errors like this:

    ../mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp: In function 'emac_interface_t* wifi_emac_get_interface()':
    ../mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp:331:38: error: use of deleted function 'emac_interface::emac_interface()'
             _intf = new emac_interface_t();
                                          ^
    In file included from ../mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp:9:0:
    ../mbed-os/hal/emac_api.h:150:16: note: 'emac_interface::emac_interface()' is implicitly deleted because the default definition would be ill-formed:
     typedef struct emac_interface {
                    ^
    ../mbed-os/hal/emac_api.h:150:16: error: uninitialized const member in 'struct emac_interface'
    ../mbed-os/hal/emac_api.h:151:32: note: 'const emac_interface_ops_t emac_interface::ops' should be initialized
         const emac_interface_ops_t ops;

This commit contains a proposed change which fixes this issue by not
using the new operator to allocate the emac_interface_t structure but
instead using the malloc() function since the construction is being
handled explicitly in the subsequent lines of the
wifi_emac_get_interface() function anyway.

I also added code which only completes the initialization of the _intf
object if its allocation succeeds and just returns NULL otherwise.

I see no deallocation of the _intf object occurring so no change from
delete to free() needed to be made.

When attempting to perform a test build of various mbed-os targets with
GCC configured to build -std=gnu++11, all of the targets built
successfully except for this one. It gave errors like this:
    ../mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp: In function 'emac_interface_t* wifi_emac_get_interface()':
    ../mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp:331:38: error: use of deleted function 'emac_interface::emac_interface()'
             _intf = new emac_interface_t();
                                          ^
    In file included from ../mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp:9:0:
    ../mbed-os/hal/emac_api.h:150:16: note: 'emac_interface::emac_interface()' is implicitly deleted because the default definition would be ill-formed:
     typedef struct emac_interface {
                    ^
    ../mbed-os/hal/emac_api.h:150:16: error: uninitialized const member in 'struct emac_interface'
    ../mbed-os/hal/emac_api.h:151:32: note: 'const emac_interface_ops_t emac_interface::ops' should be initialized
         const emac_interface_ops_t ops;

This commit contains a proposed change which fixes this issue by not
using the new operator to allocate the emac_interface_t structure but
instead using the malloc() function since the construction is being
handled explicitly in the subsequent lines of the
wifi_emac_get_interface() function anyway.

I also added code which only completes the initialization of the _intf
object if its allocation succeeds and just returns NULL otherwise.

I see no deallocation of the _intf object occurring so no change from
delete to free() needed to be made.
@bulislaw
Copy link
Member

bulislaw commented May 1, 2017

@andreaslarssonublox

@andreaslarssonublox
Copy link

Thanks for the bugfix. It looks good to me.

@0xc0170
Copy link
Contributor

0xc0170 commented May 2, 2017

/morph test

@mbed-bot
Copy link

mbed-bot commented May 2, 2017

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 121

All builds and test passed!

@theotherjimmy theotherjimmy merged commit 3c5f2c8 into ARMmbed:master May 2, 2017
exmachina-auto-deployer pushed a commit to exmachina-dev/mbed-os that referenced this pull request May 16, 2017
…lwip_broadcast

Release mbed OS 5.4.5 and mbed lib v142

Ports for Upcoming Targets

Fixes and Changes

4059: [Silicon Labs] Rename targets ARMmbed#4059
4115: Support for Qt Creator Generic project export and associated Makefile ARMmbed#4115
3915: Feature vscode ARMmbed#3915
4205: tests: race test - add not supported for single threaded env ARMmbed#4205
4187: [NCS36510] Reduce default heap size allocated by IAR to 1/4 of RAM ARMmbed#4187
4145: test - add nanostack to examples.json file ARMmbed#4145
4093: Update.py: New feature - update a branch instead of a fork, plus general improvements. ARMmbed#4093
4225: fixed missing device_name for xDot and removed progen ARMmbed#4225
4243: Config: config header file should contain new line ARMmbed#4243
4251: Fix C++11 build error w/ u-blox EVK-ODIN-W2 ARMmbed#4251
4236: STM32 Fixed warning related to __packed redefinition ARMmbed#4236
4224: Add `mbed new .` output to export ARMmbed#4224
4190: LPC4088: Enable LWIP feature ARMmbed#4190
4136: Error when bootloader is specified but does not exist ARMmbed#4136
3881: Remove debug links to printf/exit in NDEBUG builds ARMmbed#3881
4260: Inherit Xadow M0 target from LPC11U35_501 ARMmbed#4260
4249: Add consistent button names across targets ARMmbed#4249
4254: Removed unused variable in TARGET_NXP/lpc17_emac.c ARMmbed#4254
aisair pushed a commit to aisair/mbed that referenced this pull request Apr 30, 2024
Ports for Upcoming Targets


Fixes and Changes

4059: [Silicon Labs] Rename targets ARMmbed/mbed-os#4059
4187: [NCS36510] Reduce default heap size allocated by IAR to 1/4 of RAM ARMmbed/mbed-os#4187
4225: fixed missing device_name for xDot and removed progen ARMmbed/mbed-os#4225
4251: Fix C++11 build error w/ u-blox EVK-ODIN-W2 ARMmbed/mbed-os#4251
4236: STM32 Fixed warning related to __packed redefinition ARMmbed/mbed-os#4236
4190: LPC4088: Enable LWIP feature ARMmbed/mbed-os#4190
4260: Inherit Xadow M0 target from LPC11U35_501 ARMmbed/mbed-os#4260
4249: Add consistent button names across targets ARMmbed/mbed-os#4249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants