Search code examples
gccembeddedreal-timereentrancy

gcc and reentrant code


Does GCC generate reentrant code for all scenarios ?


Solution

  • Reentrancy is something that ISO C and C++ are capable of by design, so that includes GCC. It is still your responsibility to code the function for reentrancy.

    A C compiler that does not generate reentrant code even when a function is coded correctly for reentrancy would be the exception rather than the rule, and would be for reasons of architectural constraint (such as having insufficient resources to support stack, so generating static frames). In these situations the compiler documentation should make this clear.

    Some articles you might read: