Return

Libraries and tools

Here's some miscellaneous programming libraries and tools that I felt like sharing.


Libraries

Strlz - A simple dynamic string for C. Makes interacting with strings in C much less annoying.

Tools

setcmd - A command line tool that moves/resizes the CMD window.

Arrays?

I considered releasing a lazy array library similar to strlz, but unfortunately there's no very good way to make one in C. I use several different ones in my own code depending on what I want out of it, and they all have their drawbacks. My Strlz equivalent on the other hand is the same one I use for almost everything.

One of the big problems with arrays in C is that you want to change the type of the data pointer for each array. So an int array uses an int pointer, and float array uses a float pointer, and so on, otherwise you do not get type checking which leads to all kinds of problems and bugs. The only way to solve this is to require you to define a new array type every time you want to store something new into an array:

typedef struct {
	int barks;
	int woofs;
} Dog;

typedef struct ARRLZ(Dog) Arrlz_Dog;

void main () {
	Arrlz_Dog dogs = new_arrlz(Arrlz_Dog);
	
	Dog doggo = {.barks=50, .woofs=10};
	arrlz_append(&dogs, &doggo);
}

That's pretty much what I do in my code. This still has a couple problems, it works but it doesn't make me happy enough to want to share it. You can use templates in C++ to define new arrays on-the-fly but I don't want to use C++:

struct Dog {
	int barks;
	int woofs;
};

void main () {
	Arrlz<Dog> dogs = new_arrlz<Dog>();
	
	Dog doggo = {.barks=50, .woofs=10};
	arrlz_append(&dogs, &doggo);
}