esp-idf-notes

Notes for esp idf, cmake, make and kconfig

View on GitHub

Macros

#include <stdio.h>

#define AGE 23

int main(int argc, char *argv[])
{
	printf("%d\n", AGE);
}

So, it is as good as writing:

#include <stdio.h>

int main(int argc, char *argv[])
{
	printf("%d\n", 23);
}

23 got copied in place of AGE. below is a example of a function

#include <stdio.h>

#define SUM(x, y) (x + y)

int main(int argc, char *argv[])
{
	int a = 5;
	int b = 10;
	int sum = SUM(a, b);
	printf("%d\n", sum);
}

So, it is as good as writing:

#include <stdio.h>

int main(int argc, char *argv[])
{
	int a = 5;
	int b = 10;
	int sum = (a + b);
	printf("%d\n", sum);
}