AnsweredAssumed Answered

getopt - command line options parsing

Question asked by Delbergue on Oct 4, 2017
Latest reply on Oct 16, 2017 by Delbergue

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!

Outcomes