Hi all,
I'm trying to use getopt (from <unistd.h>) in some LPC-projects, where I have a small shell running.
Part of this shell is doing the command line processing, where I then need to process different kind of options.
I would like this to be as generic as possible, hence getopt().
The problem I'm facing at the moment is when playing around with heap/stack, I often get a HardFault.
This is because I don't know the memory usage/needs of getopt().
Is there a way to estimate its max usage, without having access to the implementation?
I know using such function on an embedded target might be discouraged, but re-inventing the wheel each time is also not really convenient, nor maintainable.
(Or has someone an alternative or better ideas ?)
My configuration:
LPCOpen C++ project with NewLib
MCUXpresso
LPC1769
Thanks for your help!
Hi Julien Delbergue,
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi jeremyzhou,
Thanks for your answer.
I don't think it actually is because of memory layout (12.9 btw in the latest user's guide).
I suspect it is because I'm using C++, and most likely this getopt implementation is using malloc, which is discouraged in C++ from what I am reading.
Could you maybe confirm that malloc is being used in your getopt implementation ?
I'm still open to alternatives or other ideas.
Cheers,
Julien