Headerless C programming with a single preprocessor macro line

Header files in C can be painful. They duplicate the file count, increase complexity heavily, make refactoring painful. There are solutions to get rid of them. It's possible to use header generators ( https://www.hwaci.com/sw/mkhdr/ - makeheaders ), write you own headerless c dialect with a precompiler like me ( https://github.com/milgra/clc class-c ) or use "#ifdef FOO_IMPLEMENTATION" blocks inside header files to define everything in one file but they are unelegant and confusing and have a lot of other problems.

The ultimate solution seems to be using the __INCLUDE_LEVEL__ preprocessor macro. It's value is zero if we are in a source file that was added directly to the compiler as parameter and greater than zero if we are in a file that was included as a header file from an other file.

So just create a single file, write the header declarations at the top, write the implementation under that and guard the implementation with an #if __INCLUDE_LEVEL__ == 0 macro and you never have to use header files again. You can include all files written this way as header files and add these files as source files to the compiler, everything will work as before.

Example : mtvec.c

#ifndef mtvec_h
#define mtvec_h

#include <stdio.h>
#include <stdint.h>

typedef struct mtvec_t mtvec_t;

struct mtvec_t
    void** data;
    uint32_t length;
    uint32_t length_real;

mtvec_t* mtvec_alloc(void);
void mtvec_dealloc( void* vector );
void mtvec_reset( mtvec_t* vector );


#if __INCLUDE_LEVEL__ == 0

mtvec_t* mtvec_alloc( )
    mtvec_t* vector = mtmem_calloc( sizeof( mtvec_t ) , mtvec_dealloc );
    vector->data = mtmem_calloc( sizeof( void* ) * 10 , NULL );
    vector->length = 0;
    vector->length_real = 10;
    return vector;

void mtvec_dealloc( void* pointer )
    mtvec_t* vector = pointer;

    for ( uint32_t index = 0 ; index < vector->length ; index++ ) {
    mtmem_release( vector->data[index] );
    mtmem_release( vector->data );

void mtvec_reset( mtvec_t* vector )
    for ( uint32_t index = 0 ; index < vector->length ; index++ ) 
        mtmem_release( vector->data[index] );

    vector->length = 0;


At the moment I don't see any pitfalls in this solution, do you? Please add your thoughts in the issues, thank you.

check out the github project

Comment on Headerless C programming with a single preprocessor macro line

File System Change Logger

Running a program or installing a dev environment pollutes the computer with a lot of visible/hidden/unknown of files. If you are as curious as me about file changes/additions/removals on the file system try my new tool called fschangelog. It creates lightweight file system snapshots using the file size and last modified date only and compares these snapshot files. It groups the results in three groups : added, removed and updated. It is on github with a public domain license, just download the project and compile the *.c files and there you are.

fschangelog on github

Comment on File System Change Logger

Programming Concepts For Children

I'm always thinking about how programming should be introduced to children and how to reach real programming languages with them. Here is what I've figured out so far. Feel free to contribute by comments or through github.

GitHub project

Comment on Programming Concepts For Children

Merry Christmas!

I sing in a jazz choir and it is a very important part of my life, I'm really grateful that altough I'm just a gifted amateur they accepted me. Please listen to one of my favorite Keep Smiling Jazz Vocal songs - Michelle, originally from the Beatles.

Comment on Merry Christmas!

Shockwaves of a quickly written app

High Sierra Media Key Enabler is the most successful app in my life and it took the shortest time to write. It soon reaches ten thousand downloads and it took me about 30 minutes to write it and test it. Funny. Sometimes you really have to be in the right place at the right time - wrong place at the right time or wrong time in the right place is not enough :)

I just thougt that it would be useful for others - but after a few days thanking and praising comments started to appear under my post, feature requests came and then new pull requests and issues appeared under the github project. I was super amazed. A friend told me that I should put a paypal link at the top of my homepage - and I did. And donations started to come. Right now the amount of donations reached the price of the dev license I had to buy to raise trust in the app - Thank you!

You requested a secured app, explicitly selectable players - I was against the idea first but you convinced me, automatically starting players, bugfixes, features that couldn't be added or have to be inspected, you sent issues and pull requests implementing the requested features, you are super!

Thank you, beautiful people.

Comment on Shockwaves of a quickly written app

Airpods Tricks

As soon as Airpods entered the market back in 2016 November I ordered one because I really needed reliable wireless earphones for running after a year with a terrible JBL. And it lived up to the expectations, I never heard any cracking sound or breaking music during running any more which is super cool. But controls were a little bit limited - bringing up siri with a double tap was totally useless for me and I never checked Airpods settings for more options because I'm lazy. How wrong was I!

It turned out that you can set up double tap functions for both sides individually.

Left double tap became play/pause, right double tap became next song - and there, I can do more with the airpods than with the earpods - besides volume control. I really miss volume control, but sound check in the Music app/iTunes helps in this problem a lot.

Anyway, I'm super satisfied with the Airpods, it's Apple's best new product in years. Even with the constant putting up/taking down of the earhoox beacuse of my monkey ears.

Comment on Airpods Tricks

Control Room

For a company hackathon I came up with a 3D web conferencing idea, I really wanted to feel like I'm inside of a control room and everything and everyone is around me. So I wrote a prototype with C and OpenGL that can use an arbitrary number of pre-recorded videos to demonstrate the idea. Altough I didn't win :(, you can try it here, now, in the browser. Listen to the videos carefully and use the arrow keys to navigate.

Control Room

Comment on Control Room


There was a time when I thought that object-orientation is the cure for all diseases and everything should be object-oriented. I already felt that C++ is way too over-engineered and Java is not low-level enough for me so I came up with my own object-oriented C version. After I finished and wrote a few programs/games in it I realized that the problem for me is not the language, it's the object-orientation. It should be used only in special cases not all the time. Functional programming is better, but keeping the code minimalistic aaand readable at the same time is the best, no matter what paradigm you use. So I stucked with C.

Anyway, check it out if you are interested :


Comment on Class-C



The psychedelic tunnel-runner.

"You are a thought. A thought to be born..."

Guide your thought through the labyrinth of the brain, avoid hitting the walls and obstacles, nothing should distract you...

A minimalistic-ambient reflex game with a 60 frames per second flow experienceand the atmospheric music of Tamas Katai.

Cortex is open-source, feel free to learn how to write muti-platform C games here

I want it now!

for iOS - App Store link

for Android - Google Play link

for Windows/MacOS/Linux - Steam Store link

for RaspBerry - Download ( enable OpenGL / Full KMS Support in raspi-config )

Cerebral Cortex

"SO ADDICTING AND AMAZING - Just downloaded the game and started playing and became instantly addicted. A very interesting concept! I highly recommend it especially for only .99 cents" 5/5 USA

"I've never seen anything like that before. For the price, it's totally worth it! Love the modern-retro atmosphere." 5/5 Hungary

"I thoroughly enjoyed the journey through this game and had no qualms with the simplicity of the gameplay, since the difficulty made me push harder and harder each time. Great game, great music (maybe the vocals are a bit much) and overall smooth mechanics that took me for a ride more than once." 5/5 Denmark

Surgical precision required byOctobop Find out who is the real genius among you: the neuro-surgeons talk the talk, but can they handle the Cortex? Just the right amount of subtle but fast-paced taps are needed to guide your precious thought through the brain. Get too excited and splat. Great competition for your friends: apparently for some people it's a breeze, and others (like me) crash into walls a lot. :-) I'm getting better though. Can't let the nerds beat me! Good music! Needs instructions: tap sides of screen to shift dot through the maze.

Beauty true beauty byerrolgarner There is no point using words to explain how great this game is, just play it

Instant, miminalistic, strong flow experience byNavajonki1987greatapp Up front: If you’re looking for a deep plot with characters and the usual game elements this will surprise you. It’s a very simple game, but is incredibly captivating. As you progress through the different levels, you must focus simply on not loosing focus. If you’re into games like Super Hexagon and appreciate minimalistic, finely crafted games, try this out.

Хорошая игра, правда byБогдан Рыжий Не понимаю почему она столь не популярна.

手感好,很动感 bylovehaco 像素风闪避游戏里面感觉是很好玩的了,就是眼睛容易花

挺锻炼反应速度的、geek 游戏,我喜欢哈哈!!

Comment on Cortex



Brawl is a game about intense action with super realistic physics. You have to lead your gang to victory in a crime-infected town.

You have to improve your fighting skills continuously, learn to block attacks, punch or kick with the correct timing. Watch your health and energy state. You can pick up fainted opponents/friends and use guns.


  • Intense action
  • Fluid animation
  • 6 different scenes
  • Responsive controls
  • Dozens of buddies and enemies

Brawl is open-source, feel free to learn how to write muti-platform C games here

I want it now!

Apple App Store link ( for iPhone/iPad )

Google Play Store link ( for phones/tablets )

Steam Store link ( for MacOS/Windows/Linux )

Raspberry Pi download link

Try it in the browser

Mass Brawl

Comment on brawl