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

ATHandler.cpp malloc undefined #10352

Closed
wajahat-ublox opened this issue Apr 9, 2019 · 5 comments

Comments

Projects
None yet
3 participants
@wajahat-ublox
Copy link
Member

commented Apr 9, 2019

Description

I am getting build errors if cellular traces are enabled. The error points to this line. Wouldn't it be better to use new/delete instead of malloc free as we are in .cpp?

Building project latestmbed (UBLOX_C027, ARMC5)
Scan: latestmbed
Compile [100.0%]: ATHandler.cpp
[Error] ATHandler.cpp@1292,0:  #20: identifier "malloc" is undefined
[Error] ATHandler.cpp@1322,0:  #20: identifier "free" is undefined
[ERROR] ".\mbed-os\features\cellular\framework\AT\ATHandler.cpp", line 1292: Error:  #20: identifier "malloc" is undefined
".\mbed-os\features\cellular\framework\AT\ATHandler.cpp", line 1322: Error:  #20: identifier "free" is undefined
.\mbed-os\features\cellular\framework\AT\ATHandler.cpp: 0 warnings, 2 errors

Issue request type

[ ] Question
[ ] Enhancement
[X] Bug
@0xc0170

This comment has been minimized.

Copy link
Member

commented Apr 9, 2019

@hasnainvirk

This comment has been minimized.

Copy link
Contributor

commented Apr 9, 2019

@wajahat-ublox Interesting. It shouldn't matter how you allocate memory. Malloc is just as fine as new although there morphology is different. Are you sure you are not running out of memory at the point you twiddle the traces on ? May I ask the name and specs of the board you are using ?

@hasnainvirk

This comment has been minimized.

Copy link
Contributor

commented Apr 9, 2019

Please share your error log as well.

@wajahat-ublox

This comment has been minimized.

Copy link
Member Author

commented Apr 9, 2019

@hasnainvirk
Yes technically both are same, in fact i think mbed calls malloc from new. However if i replace the malloc with new calls, then it builds fine.

I don't think i am running out of memory because i am talking about compilation error while building with traces enabled.

Building project dl_test (UBLOX_C027, ARMC5)
Scan: dl_test
Compile [100.0%]: ATHandler.cpp
[Error] ATHandler.cpp@1292,0:  #20: identifier "malloc" is undefined
[Error] ATHandler.cpp@1322,0:  #20: identifier "free" is undefined
[ERROR] ".\mbed-os\features\cellular\framework\AT\ATHandler.cpp", line 1292: Error:  #20: identifier "malloc" is undefined
".\mbed-os\features\cellular\framework\AT\ATHandler.cpp", line 1322: Error:  #20: identifier "free" is undefined
.\mbed-os\features\cellular\framework\AT\ATHandler.cpp: 0 warnings, 2 errors
@hasnainvirk

This comment has been minimized.

Copy link
Contributor

commented Apr 9, 2019

@wajahat-ublox Alright. Thanks, one way to fix it would be to add stdlib.h explicitly in ATHandler.cpp. But I like your approach. Let's use new instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.