arena icon indicating copy to clipboard operation
arena copied to clipboard

`Region` pollutes namespace

Open Pecora0 opened this issue 4 months ago • 3 comments

arena.h defines the type Region which is a very generic name. This can easily result in naming collisions when arena.h is included into a project. This feels especially unnecessary because the user of the library is not really supposed to use the Region type from this library. It is just a minor inconvenience but it would be nice to avoid. Maybe Region can be prefixed?

Pecora0 avatar Oct 24 '25 13:10 Pecora0

Has it already caused actual issues for you?

rexim avatar Oct 24 '25 16:10 rexim

Apparently Xutil.h defines a type called Region.

#include <stdio.h>

#define ARENA_IMPLEMENTATION
#include "arena.h"

#include <X11/Xutil.h>

int main(void) {
    printf("hello\n");
}

This code throws an error when compiled with

$ gcc -o main main.c

I noticed this when I tried out RGFW after one of your streams because RGFW includes X11 libraries (on linux). As a workaround I included RGFW only as a header and compiled the RGFW code separately. It works fine but it is inconvenient.

Pecora0 avatar Oct 25 '25 10:10 Pecora0

imo the best solution would be a prefix but there are probably other work too. For instance in Raylib RGFW links windows.h which has plenty of conflicts and so I had to do something like this:

#define Region Region_X11

#include "RGFW.h"

#undef Region

ColleagueRiley avatar Nov 03 '25 05:11 ColleagueRiley