3 ms·
Yes, C's stack usage can be unintuitive when working in a constrained environment, especially when accustomed to the affordances of desktop operating system. I
by thadt 3y ago
Yes, C's stack usage can be unintuitive when working in a constrained environment, especially when accustomed to the affordances of desktop operating system. I once joined a project where several developers had spent a couple weeks trying to track really hard to pin down bugs in several subsystems they were developing in a microcontroller codebase. They would move things around and the bugs would move. After tracing things a bit and setting a trap, I found the places in the codebase where the call stack got too deep and was scribbling over other data structures.
- JonChesterfield 3y agoPutting a `out-of-stack? branch` check in every function prolog made an embedded chip programmed in C much nicer to work with. Cost a few instructions which was contentious but definitely a development aid.
- PaulHoule 3y agoRecursion is a bad thing in embedded systems and generally overrated in CS pedagogy. It can be useful in analyzing algorithms but often in cases like search it is a "second best" answer compared to say, using nondeterminism.