Skip to content

zenkoo/macros

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


#macros.h

Useful C #macros
Visit macros »

Open Source Love MIT Licence Build Status Codacy Badge

This is a collection of commonly used C Macros I found on internet, and as suggested by my friends.

Why this is awesome

Using C Macros, we can extend C with a lot of useful functionality. For example, we can create loops like foreach which are very useful and handy when it comes to arrays. These are available in most of high level languages but not in C. But we got macros in C and so we can add on our own!

How to use

Just download macros.h from here and include it to the top.

#include "macros.h"

Note that there is an ASSET macro useful for debugging purpose. To enable it, you need to #define DEBUG before including macros.h.

And these are the macros...

For docs, visit ramdeoshubham.com/macros to learn more about the available macros and their usage.

Contribute

The source is very clear and the macros available are too common you will find them everywhere. A good Macro is : Portable, safe, involves as less arbitrary variables as possible. Although I am trying my best, there might be some exception errors, please correct if you find any. Also, if I missed some other interesting macros, please contribute to make this collection complete and more usable.

Conventions

  1. All macros are in UPPERCASE.
  2. In case of any Boolean Macro, the IS_ prefix should be used. For example, IS_EVEN(x). And they should return a 1 or 0 value.
  3. Macros for loops and conditionals should not end with braces so that the user can have the option for single line as well as block style.
  4. A helper macro, which are expanded by some other main macro, usually they are not intended to be used directly. So they should be mentioned with their expansion level as prefix. For example, PASTE(a,b) expands into PASTE2(a,b) which further expands into a##b.

Credit

The real credits goes to all those great C coders who came up with such creative use of C Macros to extend C. I made this collection in honor of The C language and those unknown programmers. I can only take credit for the efforts I made to collect and bringing it to you.

License

Copyright 2017, Shubham Ramdeo. Code released under the MIT License.

#Handpicked C #Macros with ♥ #love !

Don't forget to STAR if you like it.

About

A collection of commonly used C MACROS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • C 98.8%
  • Makefile 1.2%