Skip to content

Consider using macros instead of -D to support "quick compiling" #544

@IngwiePhoenix

Description

@IngwiePhoenix

Hello!

Obviously, in it's current state, this fails quite badly:

[email protected] ~/W/G/d/out $ gcc ../kernel/*.c -o dao
../kernel/daoPlatform.c:101:2: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]
        gettimeofday( & tv, NULL);
        ^
1 warning generated.
../kernel/daoVmspace.c:2848:8: warning: implicit declaration of function 'getcwd' is invalid in C99 [-Wimplicit-function-declaration]
        cwd = getcwd( masterVmSpace->startPath->chars, 511 );
              ^
../kernel/daoVmspace.c:2848:6: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
        cwd = getcwd( masterVmSpace->startPath->chars, 511 );
            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
[email protected] ~/W/G/d/out $ ./dao
fish: './dao' terminated by signal SIGSEGV (Address boundary error)

When using the (dao)makefiles, I see that only a few definitions are actually added, such as -DMACOSX or -DBSD and -DUNIX. This can, in fact, easily be deduced off a few #ifdef checks:

#ifdef __APPLE__
#define MACOSX
#define BSD
#define UNIX
#endif

There is a super comprehensive "feature detection" header here: https://github.com/msadeqhe/platform-id/blob/master/include/platform-id.h

You may be able to pick this up and modify it to automatically define DAO_-macros. This would make blind-compiles like my showcase above possible, simplify the bootstrap process a little and also allow for people with neither make nor any other means of building, to compile this language right away.

Kind regards,
Ingwie.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions