Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coding-pelican/macrometa
Macrometa: Macro Metaprogramming (MCMT) Library for C
https://github.com/coding-pelican/macrometa
c c11 header-only language macros metaprogramming preprocessor programming-language recursion turing-tarpit
Last synced: about 13 hours ago
JSON representation
Macrometa: Macro Metaprogramming (MCMT) Library for C
- Host: GitHub
- URL: https://github.com/coding-pelican/macrometa
- Owner: coding-pelican
- License: mit
- Created: 2023-10-10T08:04:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-14T08:28:01.000Z (about 1 year ago)
- Last Synced: 2023-10-15T16:10:24.461Z (about 1 year ago)
- Topics: c, c11, header-only, language, macros, metaprogramming, preprocessor, programming-language, recursion, turing-tarpit
- Language: C
- Homepage:
- Size: 1.25 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Macrometa: Macro Metaprogramming (MCMT) Library for C
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
## Overview
Macrometa (MCMT) is a powerful macro-based library for C that enables metaprogramming, allowing developers to generate complex code during compile-time using preprocessor macros. It is inspired by the article "C/C++ Preprocessor Metaprogramming" by Saad Ahmad and various C preprocessor tricks, tips, and idioms.
### Key Features
- **Metaprogramming Tools**: MCMT provides a wide range of macros for handling empty arguments, manipulating identifiers, concatenating macros, overloading macros, and more.
- **Based on C11 Standard**: MCMT is based on the C11 standard, ensuring compatibility with modern C compilers.
## Library Sections
The MCMT Library is organized into several sections, each dedicated to specific macro functionalities:
- **mcmt_basic**: Basic macros for handling empty arguments and expansions.
- **mcmt_concat**: Macros for concatenating and manipulating identifiers.
- **mcmt_cat**: Macros for complex identifier concatenation and deferring macro calls.
- **mcmt_extn_impl_ovld**: Macros for extending, implementing, and overloading generic macros.
- **mcmt_arg**: Macros for manipulating and counting arguments.
- **mcmt_bit_logic**: Macros for bitwise logic operations.
- **mcmt_logic**: Macros for boolean and logical operations.
- **mcmt_list**: Macros for handling lists and checking for emptiness.
- **mcmt_tuple**: Macros for working with tuples and enclosed expressions.
- **mcmt_for_each**: Macros for iterating through lists and applying operations.
- **mcmt_compare**: Macros for comparing and checking the existence of macro arguments.
- **mcmt_arith**: Macros for basic arithmetic operations.
- **mcmt_range**: Macros for generating ranges of values.## Getting Started
To use the MCMT Library in your project, include the `mcmt.h` header file and start leveraging the macros provided by the library. Here's a very simple example:
```c
#include "macrometa.h"
#include// Define a macro to square a number.
#define SQUARE(x) MUL(x, x)int main() {
int result = SQUARE(5); // Expands to 25 at compile-time.
printf("Square: %d\n", result);
return 0;
}
```## License
This library is distributed under the [MIT License](LICENSE).
## Contributing
Contributions to the MCMT Library are welcome! Feel free to open issues or submit pull requests on the [GitHub repository](https://github.com/coding-pelican/macrometa).
## Author
- **Gyeongtae Kim (DevDasae, @coding-pelican)** - [[email protected]](mailto:[email protected])
For more information and updates, visit the [GitHub repository](https://github.com/coding-pelican/macrometa).
---
*This library is based on the C11 standard.*