Hi Divya,
This is a common issue when compiling MEX files for MATLAB or Octave with newer versions of GCC (like GCC 15.x). The error about bool being undefined, even after including <stdbool.h>, is usually caused by a conflict between MATLAB's (or Octave's) own type definitions and those in the system headers.Root Cause
- matrix.h (provided by MATLAB/Octave) sometimes defines its own bool type or expects an older C standard.
- GCC 15.x is stricter and may expose conflicts between the C99 bool (from <stdbool.h>) and any custom bool definitions.
- If you have #define bool or similar in your code or in matrix.h, it can cause this error.
1. Include Order Matters
Always include matrix.h before including <stdbool.h> or any other system headers
2.Check for Redefinition
Make sure neither your code nor matrix.h is redefining bool.
If you see something like:
remove or guard it with:
3.Check MATLAB/Octave Version Compatibility
Older versions of MATLAB/Octave may not be compatible with newer GCC.
- Check if there's an update or patch for MATLAB/Octave for GCC 15.x support.
- If not, consider downgrading GCC (e.g., to GCC 11 or 12) for MEX compilation.