CProtoGen is an intuitive Python library and command-line tool that simplifies the task of generating C function prototypes from your source files. Whether you're a seasoned developer or just starting out, our tool helps you streamline your workflow by automatically creating or updating header files, freeing you to focus on writing code.
CProtoGen is a versatile Python library and command-line tool designed for developers who need to streamline the process of generating C function prototypes from source files. With CProtoGen, you can effortlessly create and update header files based on your existing C code, making it an invaluable asset for any C development workflow.
Key Features
- Generate C Function Prototypes: Automatically derive function prototypes from C source files, ensuring your header files are always up-to-date.
- Flexible Integration: Use CProtoGen as a Python library or directly from the command line, adapting to your preferred development style.
Usage Examples
Library Integration
Easily generate prototypes using the CProtoGen API:
from cprotogen.generator import generate_prototypes
source_files = ["file1.c", "file2.c", "file3.c"]
for source in source_files:
header = source.replace(".c", ".h")
generate_prototypes(source, header, overwrite=True)
print(f"Updated {header} with prototypes from {source}")
Command-Line Tool
Leverage the command-line interface for quick access:
# Generate prototypes and create/update a header file
cprotogen path/to/source.c --header path/to/header.h
# Generate prototypes and overwrite existing header file
cprotogen path/to/source.c --header path/to/existing_header.h --overwrite
# Display help information
cprotogen -h
Generating Prototypes with Example Code
Here’s how you can generate prototypes based on your C files:
- For a Simple Function:
generate_prototypes("hello.c", "hello.h")
This will produce the header file hello.h
containing the necessary prototypes.
- Updating an Existing Header:
# Update your header as your source code evolves
generate_prototypes("hello.c", "hello.h", overwrite=True)
This ensures that your prototypes are in sync with the latest function definitions.
- Generate Prototypes Without Header File:
prototypes = generate_prototypes("hello.c")
print(prototypes) # Outputs the function prototypes directly.
CProtoGen is designed to enhance your workflow by reducing manual errors, saving time, and automating repetitive tasks in C programming. Simplify your development process with CProtoGen today!