What is micro-C?


micro-C is simplified C language, stripped of certain functionalities that it contains. The very basic idea of micro-C is simplicity and avoidance of complicated language constructs in order to produce clean and understandable hypothetical assembly code.

Supported


Function definitions
int fibonacci (int x) {
	if (x <= 1) 
		return 1;
	return fibonacci(x - 1) + fibonacci(x - 2);
}
Global variable definition ( int and int * type)
int x = 1;
int main() {
	return x;
}
Local variable definition ( int and int * type)
int main() {
	int a = 1;
	int * b = 1;
	int c[] = {1, 2, 5};

	int r;
	int * d, e, f[], g = 3, h = r = 5;
}
Pass by value and pass by pointer
int swap(int * x, int * y) {
	int temp = *x;
	*x = *y;
	*y = temp;
}
Arrays
int arr[10];
int x = arr[5];
Arithmetic expressions
int x = 1;
int * y = malloc(sizeof(int));
* y = 1;
int z = ++x + *y;
z *= 3;
z = x << 2;
Logical expressions
if (!x && y > 2) {
	return 0;
} else {
	return function(x + y);
}
while (x--) {
	y += 2;
}
Parenthesis in arithmetic expressions
x = (y + z) * 3 / (q << 2);

Not supported


Pointer to a function
int foo(int x) {
	return x;
}

int bar() {
	int (*ptr2func)(int);
	ptr2func= foo;
	int x = ptr2func(2);
}
Pointer as a function return value
int * foo() {
	int * x = malloc(sizeof(int));
	*x = 1;
	return x;
}
Parenthesis in logical expressions
if (x == 1 && (y == 2 || z == 3)) {
	...
}
Standard input and output
printf();
scanf();
Directives
#include<stdio.h>
For loops
for (int i = 0; i < 10; i++) {
}
NULL keyword
int * x = NULL;