Remove Includes: Clean, Self-Contained Source Files for Maximum Portability

emmtrix Tech Posts
Category: General Transformations

Part of our transformation series in emmtrix Studio

What does it do?
The Remove Includes Transformation removes all non-standard #include directives from a C file and replaces them with the actual declarations (e.g., function prototypes, structs, macros) extracted from the headers.

The result? A self-contained, readable, and directly compilable .c file – no external headers required.

Why use it?

▪️ Generate standalone files for testing, simulation or external distribution
▪️ Debug more easily by flattening complex include hierarchies
▪️ Export clean code for toolchain-agnostic workflows
▪️ Reduce dependency on custom or inaccessible header structures
▪️ Useful in embedded and autogenerated code environments

Example
The post image shows a before/after comparison: #include directives are removed and replaced with the declarations needed for compilation – clean and header-free.

Figure 1: Example Remove Includes Transformation

Integration
Available via #pragma EMX_TRANSFORMATION_GLOBAL RemoveIncludes or via GUI in emmtrix Studio. System headers like <stdio.h> remain untouched.

Cookie Consent with Real Cookie Banner