I attempted to use a combination of traits and mixins to automatically create aliases of names in SDL2 without the SDL_ prefix for convenience. However, I was only able to achieve this for functions in the module, and not for types nor enum values. How could I go about achieving the desired result? Here is the code I'm using in an intermediate "sdl_stripped" module:

import std.regex;
import std.array;
public import derelict.sdl2.sdl;

string StripSDLPrefix() {
    auto members = [__traits(allMembers, derelict.sdl2.internal)];
    foreach(ref member; members) {
        if (member.length > 4 && member[0..4] == "SDL_") {
member = "alias " ~ member[4..$] ~ " = " ~ member ~ ";\n";
        else {
            member = "";
    return members.join();


// I added this to print the list of generated names for debugging purposes.
static if (false) {
    pragma(msg, StripSDLPrefix());

Reply via email to