Expand description
§C Preprocessor Library
This library provides a complete C preprocessor implementation that can process C/C++ source code with macros, conditional compilation, and includes. It supports target-specific preprocessing for different operating systems and compilers.
§Features
- Macro expansion (object-like and function-like macros)
- Conditional compilation (
#ifdef,#ifndef,#if,#else,#elif,#endif) - Include processing with custom resolvers
- Target-specific macro definitions (Linux, Windows, macOS)
- Compiler-specific macro definitions (GCC, Clang, MSVC)
- C FFI for integration with other languages
§Example
use includium::{preprocess_c_code, PreprocessorConfig};
let code = r#"#
#define PI 3.14
#ifdef __linux__
const char* platform = "Linux";
#endif
"#;
let config = PreprocessorConfig::for_linux();
let result = preprocess_c_code(code, &config).unwrap();
println!("{}", result);Structs§
- Macro
- A preprocessor macro definition
- Preprocessor
- The main C preprocessor struct
- Preprocessor
Config - Configuration for the C preprocessor
Enums§
- Compiler
- Compiler dialect for preprocessing
- Preprocess
Error - Errors that can occur during preprocessing
- Target
- Target operating system for preprocessing
Functions§
- preprocess_
c_ code - Preprocess C code with the given configuration. This automatically defines target and compiler-specific macros.
- preprocess_
c_ file - Preprocess a C file and write the result to another file
- preprocess_
c_ file_ to_ string - Preprocess a C file and return the result as a string
Type Aliases§
- Include
Resolver - Type alias for include resolver function