Skip to content

NRF52: rename the STRINGIFY macro to avoid compiler warnings #7329

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

Closed
wants to merge 1 commit into from

Conversation

pingdan32
Copy link
Contributor

Description

The macro STRINGIFY in nordic_common.h conflicts with the macro STRINGIFY in rtx_core_cm.h, which causes the compiler to prompt a large number of warnings when using the IAR to compile the NRF52 platform.

This PR avoids these warnings by renaming it to NRF_STRINGIFY.

In addition, it is recommended that it should check if there are too many warnings when main repository merge code. Our current main repository code compiles with a lot of warnings

Pull request type

[ ] Fix
[x] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

@cmonr cmonr requested a review from marcuschangarm June 27, 2018 02:02
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 27, 2018

The changes look good but are they needed? how targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h gets outside of the nrf ? It should not, and would not cause this conflict.

@pan-
Copy link
Member

pan- commented Jun 27, 2018

@0xc0170 It may be use in Nordic ble implementation which may also need headers from the OS.

@pingdan32
Copy link
Contributor Author

pingdan32 commented Jun 28, 2018

@0xc0170 Although I don't know why, this changes is really necessary, just like the following:

PS H:\Workspace\mbed\mbed-os-example-ble\BLE_LED> mbed compile -t IAR -m NRF52_DK -c
Building project BLE_LED (NRF52_DK, IAR)
Scan: .
Scan: mbed
Scan: env
Scan: FEATURE_BLE
Using ROM regions bootloader, application in this build.
  Region bootloader: size 0x23000, offset 0x0
  Region application: size 0x5d000, offset 0x23000
Compile [  0.2%]: cmain.S
Compile [  0.3%]: mbed_tz_context.c
Compile [  0.5%]: AnalogIn.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  0.6%]: BusIn.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  0.8%]: BusInOut.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  0.9%]: BusOut.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  1.1%]: CAN.cpp
Compile [  1.2%]: Ethernet.cpp
Compile [  1.4%]: I2CSlave.cpp
Compile [  1.5%]: I2C.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  1.7%]: InterruptIn.cpp
Compile [  1.8%]: FlashIAP.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  2.0%]: InterruptManager.cpp
Compile [  2.1%]: MbedCRC.cpp
Compile [  2.3%]: RawSerial.cpp
Compile [  2.4%]: SPISlave.cpp
Compile [  2.6%]: TableCRC.cpp
Compile [  2.7%]: SPI.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  2.9%]: Serial.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  3.0%]: SerialBase.cpp
Compile [  3.2%]: Ticker.cpp
Compile [  3.3%]: Timer.cpp
Compile [  3.5%]: Timeout.cpp
Compile [  3.6%]: TimerEvent.cpp
Compile [  3.8%]: equeue.c
Compile [  3.9%]: EventQueue.cpp
[Warning] TCPServer.h@78,10: [Pe997]: function "Socket::accept(signed int *)" is hidden by "TCPServer::accept" -- virtual function override intended?
[Warning] nordic_common.h@138,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 277 of "H:\Workspace\mbed\mbed-os-example-ble\BLE_LED\mbed-os\rtos\TARGET_CORTEX\rtx5\RTX\Source\rtx_core_cm.h")
Compile [  4.1%]: UARTSerial.cpp
[Warning] rtx_core_cm.h@277,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 138 of "./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/libraries/util/nordic_common.h")
Compile [  4.2%]: equeue_posix.c
Compile [  4.4%]: equeue_mbed.cpp
[Warning] TCPServer.h@78,10: [Pe997]: function "Socket::accept(signed int *)" is hidden by "TCPServer::accept" -- virtual function override intended?
[Warning] nordic_common.h@138,0: [Pa181]: incompatible redefinition of macro "STRINGIFY" (declared at line 277 of "H:\Workspace\mbed\mbed-os-example-ble\BLE_LED\mbed-os\rtos\TARGET_CORTEX\rtx5\RTX\Source\rtx_core_cm.h")

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 28, 2018

I checked how that common gets in, via some driver includes nrf_drv_spi.h is pulled via objects.h. This can't be fixed there. This fix is fine but won't protect us in the future for other targets.

Looking at the rtx_core_cm.h - this one is to blame. Some macros have protection against redefintion but not STRINGIFY (what is probability that somewhere it's already defined ?). I'll create an issue for CMSIS_5.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 28, 2018

I created ARM-software/CMSIS_5#385. From my view, I think we can fix it in RTX as that symbol should not be exposed t here like that for just use in one line (that one is easy to fix). Do not redefine what is already defined (in this case something so generic).

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 28, 2018

Update, this should fix the warning: #7364

That Stringify should not get even to the app (we included internal RTX header file). T hus this patch should not be needed then.

@pingdan32 please review

@pingdan32
Copy link
Contributor Author

#7364 This PR is a perfect solution, I like it. Thanks.

@cmonr
Copy link
Contributor

cmonr commented Jun 29, 2018

@marcuschangarm This is a frieldly review reminder (the changeset is small and straightforward)

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 29, 2018

@marcuschangarm This is a frieldly review reminder (the changeset is small and straightforward)

We can close this one. The fix referenced above fixes warnings that were addressed also here. We don't need to edit the 3rd party drivers in this case.

Note, I do not like some macros that are exposed from nordic drivers, but that is different task to fix that (@marcuschangarm if you find time to review them, see my #7329 (comment) comment).

@marcuschangarm
Copy link
Contributor

Note, I do not like some macros that are exposed from nordic drivers, but that is different task to fix that (@marcuschangarm if you find time to review them, see my #7329 (comment) comment).

I think @TacoGrandeTX is going to take a look at those warnings in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants