{"id":20468980,"url":"https://github.com/neko-box-coder/macropowertoys","last_synced_at":"2025-08-12T02:44:12.457Z","repository":{"id":231203967,"uuid":"779278875","full_name":"Neko-Box-Coder/MacroPowerToys","owner":"Neko-Box-Coder","description":"A collection of useful C/C++ macros for manipulating arguments and preprocessing","archived":false,"fork":false,"pushed_at":"2025-07-06T06:18:18.000Z","size":71,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T07:27:58.604Z","etag":null,"topics":["c","cpp","macros","preprocessing"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Neko-Box-Coder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-29T13:07:48.000Z","updated_at":"2025-07-06T06:18:21.000Z","dependencies_parsed_at":"2024-04-03T01:45:03.794Z","dependency_job_id":"bf1c8bf9-416f-4c48-9943-058dc4c7c7f7","html_url":"https://github.com/Neko-Box-Coder/MacroPowerToys","commit_stats":null,"previous_names":["neko-box-coder/macropowertoys"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Neko-Box-Coder/MacroPowerToys","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FMacroPowerToys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FMacroPowerToys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FMacroPowerToys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FMacroPowerToys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neko-Box-Coder","download_url":"https://codeload.github.com/Neko-Box-Coder/MacroPowerToys/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FMacroPowerToys/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269991394,"owners_count":24509009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cpp","macros","preprocessing"],"created_at":"2024-11-15T14:07:31.483Z","updated_at":"2025-08-12T02:44:12.440Z","avatar_url":"https://github.com/Neko-Box-Coder.png","language":"C","readme":"# Macro Power Toys 🎲\n\nA collection of useful macros for manipulating the arguments. \nUseful codebase that needs a decent amount of preprocessing before compiling.\n\nJust include `MacroPowerToys.h` from the root repository directory and enjoy the macros.\n\n## Macros\n\n- [Appending / Concatenating items between two lists](#appending-concatenating-items-between-two-lists)\n- [Counting the number of arguments](#counting-the-number-of-arguments)\n- [Generate a list that counts up to the number](#generate-a-list-that-counts-up-to-the-number)\n- [Get the last argument](#get-the-last-argument)\n- [Check if arguments are empty or not](#check-if-arguments-are-empty-or-not)\n- [Remove parenthesis](#remove-parenthesis)\n- [Miscellaneous Macros (Concatenating, Composing)](#miscellaneous-macros-concatenating-composing)\n- [Macro Function Overloading](#macro-function-overloading)\n- [Prefixing, Suffixing, Prepending or Appending to all arguments](#prefixing-suffixing-prepending-or-appending-to-all-arguments)\n- [Persistent Counter](#persistent-counter)\n\n### Appending / Concatenating items between two lists\n\n- `MPT_APPEND_LISTS_ITEMS( commaSeparatedList1, commaSeparatedList2 )`\n- `MPT_CONCAT_LISTS_ITEMS( commaSeparatedList1, commaSeparatedList2 )`\n```c\n//Appending lists items, up to 100 items\nMPT_APPEND_LISTS_ITEMS( a1, a2, b1, b2 )\n\n//Expands to...\na1 b1, a2 b2\n\n//For example:\n#define TYPES_LIST int, char, void*\n#define NAMES _1, _2, _3\n\nMPT_APPEND_LISTS_ITEMS( TYPES_LIST, NAMES )\n\n//Expands to...\nint _1, char _2, void* _3\n\n\n\n//Similarly, to concatenate lists items, up to 100 items\nMPT_CONCAT_LISTS_ITEMS( a1, a2, b1, b2 )\n\n//Expands to...\na1b1, a2b2\n```\n\n### Counting the number of arguments\n\n- `MPT_ARGS_COUNT( arguments )`\n```c\n//Count lists items, up to 100 items\nMPT_ARGS_COUNT( a1, a2, a3, a4 )\n\n//Expands to...\n\n4\n```\n\n### Generate a list that counts up to the number\n\n- `MPT_COUNT_TO_\u003cNumber\u003e_(prefix, suffix)`\n- `MPT_COUNT_TO_\u003cNumber\u003e_MINUS_1(prefix, suffix)`\n```c\n//Create a list that counts up to 5\nMPT_COUNT_TO_5_( prefix_, /* no suffix */ )\nMPT_COUNT_TO_3_MINUS_1( _, _ )\n\n//Expands to...\n\nprefix_1, prefix_2, prefix_3, prefix_4, prefix_5\n_1_, _2_\n```\n\n### Get the last argument\n\n- `MPT_GET_LAST_ARG( arguments )`\n```c\n//Get the last argument in the list\nMPT_GET_LAST_ARG( a1, a2, a3, a4 )\n\n//Expands to...\n\na4\n```\n\n### Check if arguments are empty or not\n\n- `MPT_ARE_ARGS_EMPTY( arguments )`\n```c\n\n//Check if the list is empty\n#define EMPTY_LIST\n#define NOT_EMPTY_LIST 1, 2, 3\n\nMPT_ARE_ARGS_EMPTY(EMPTY_LIST)\nMPT_ARE_ARGS_EMPTY(NOT_EMPTY_LIST)\n\n//Expands to...\n\nEMPTY\nNOT_EMPTY\n```\n\n### Remove parenthesis\n- `MPT_REMOVE_PARENTHESIS( argument )`\n    - This removes any outer parenthesis for `argument` if there's any\n- `MPT_REMOVE_PARENTHESIS_IN_LIST( arguments )`\n    - Same as `MPT_REMOVE_PARENTHESIS` but does it for each item in the list\n\n```c\nMPT_REMOVE_PARENTHESIS( (ITEM_1) )\nMPT_REMOVE_PARENTHESIS( (ITEM_1, ITEM_2) )\nMPT_REMOVE_PARENTHESIS( ITEM_2 )\n\nMPT_REMOVE_PARENTHESIS_IN_LIST( (ITEM_1), (ITEM_1, ITEM_2), ITEM_2 )\n\n//Expands to...\n\nITEM_1\nITEM_1, ITEM_2\nITEM_2\n\nITEM_1, ITEM_1, ITEM_2, ITEM_2\n```\n\n### Miscellaneous Macros (Concatenating, Composing)\n- `MPT_CONCAT( a, b )`\n    - This has 20 copies for nested calling\n    \u003e `MPT_CONCAT2( a, b )`, `MPT_CONCAT3( a, b )`, etc...\n    - This also has a delayed version for ability to not expand immediately\n    \u003e `MPT_DELAYED_CONCAT( a, b )`, `MPT_DELAYED_CONCAT2( a, b )`, etc...\n- `MPT_COMPOSE( a, b )`\n    - This has 20 copies for nested calling\n    \u003e `MPT_COMPOSE2( a, b )`, `MPT_COMPOSE3( a, b )`, etc...\n    - This also has a delayed version for ability to not expand immediately\n    \u003e `MPT_DELAYED_COMPOSE( a, b )`, `MPT_DELAYED_COMPOSE2( a, b )`, etc...\n- `MPT_DELAY(...)` \n    - Delays the expansion of the arguments\n```c\n\nMPT_CONCAT( ITEM_1, ITEM_2 )\nMPT_COMPOSE( ITEM_1, ITEM_2 )\nMPT_DELAY(ITEM_1, ITEM_2)\n\n//Expands to...\n\nITEM_1ITEM_2\nITEM_1 ITEM_2\nITEM_1, ITEM_2\n```\n\n### Macro Function Overloading\n\n- `MPT_OVERLOAD_MACRO( macroName, arguments )`\n\n```c\n#define MACRO_FUNC_0() 0\n#define MACRO_FUNC_1( a ) a\n#define MACRO_FUNC_2( a, b ) a + b\n\n//Using MPT_OVERLOAD_MACRO to allow MACRO_FUNC to be overloaded based on number of arguments\n#define MACRO_FUNC( ... ) MPT_OVERLOAD_MACRO( MACRO_FUNC, __VA_ARGS__ )\n\nMACRO_FUNC()\nMACRO_FUNC(10)\nMACRO_FUNC(1, 2)\n\n//Expands to...\n\n0       //MACRO_FUNC_0()\n10      //MACRO_FUNC_1(10)\n1 + 2   //MACRO_FUNC_2(1, 2)\n```\n\n### Prefixing, Suffixing, Prepending or Appending to all arguments\n\n- `MPT_PREFIX_SUFFIX_ARGS( prefix, suffix, arguments )`\n- `MPT_PREPEND_APPEND_ARGS( prepend, append, arguments )`\n\n```c\nMPT_PREFIX_SUFFIX_ARGS( /* no prefix*/, _suffix, a1, a2, a3 )\nMPT_PREPEND_APPEND_ARGS( const, /* no append */, int, char, char* )\n\n//Expands to...\n\na1_suffix, a2_suffix, a3_suffix\nconst int, const char, const char*\n```\n\n### Persistent Counter\n\n- `MPT_START_COUNTER_AND_INCREMENT(name, [optional note])`\n- `MPT_INCREMENT_COUNTER([optional note])`\n- `MPT_GET_COUNT_AND_INCREMENT(name, [optional note])`\n\n```c\n\n//Given `__COUNTER__` is currently 0\n\nMPT_START_COUNTER_AND_INCREMENT(MyCounter, /* any note here */);\nMPT_INCREMENT_COUNTER(/* or no note at all */);\nMPT_INCREMENT_COUNTER(2 /* or note to keep track of current __COUNTER__ */);\n\nMPT_START_COUNTER_AND_INCREMENT(MyCounter2);\nMPT_INCREMENT_COUNTER();\nMPT_INCREMENT_COUNTER();\n\nMPT_GET_COUNT_AND_INCREMENT(MyCounter);\nMPT_GET_COUNT_AND_INCREMENT(MyCounter2);\n\n//Expands to...\n\nenum { MyCounter = 0 };\nenum { INTERNAL_MPT1 = 1 };\nenum { INTERNAL_MPT2 = 2 };\n\nenum { MyCounter2 = 3 };\nenum { INTERNAL_MPT4 = 4 };\nenum { INTERNAL_MPT5 = 5 };\n\n6 - MyCounter;  //6\n7 - MyCounter2; //4\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fmacropowertoys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneko-box-coder%2Fmacropowertoys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fmacropowertoys/lists"}