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-abbas opened this issue Apr 9, 2019 · 5 comments
Closed

ATHandler.cpp malloc undefined #10352

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

Comments

@wajahat-abbas
Copy link
Member

wajahat-abbas 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
Copy link
Contributor

0xc0170 commented Apr 9, 2019

cc @ARMmbed/mbed-os-wan

@hasnainvirk
Copy link
Contributor

@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
Copy link
Contributor

Please share your error log as well.

@wajahat-abbas
Copy link
Member Author

@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
Copy link
Contributor

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants