Skip to content

Commit

Permalink
Change default c-standard to gnu99, get rid of D_XOPEN_SOURCE define
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Dec 7, 2023
1 parent 5accda3 commit 56a0cfc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 0 additions & 1 deletion drivers/lang/c/src/gcc/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ void gcc_add_std(
} else if (lang == BAKE_SRC_LANG_C) {
ut_strbuf_append(cmd, " -std=%s ",
driver->get_attr_string("c-standard"));
ut_strbuf_append(cmd, " -D_XOPEN_SOURCE=600");
}

ut_strbuf_appendstr(cmd, " -Wall -W -Wextra -pedantic");
Expand Down
15 changes: 13 additions & 2 deletions drivers/lang/c/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ bool is_clang(bake_src_lang lang)
return is_compiler("clang", lang);
}

/* Is current compiler msvc */
static
bool is_gcc(void) {
return is_compiler("gcc", 0);
}

/* Is current compiler emcc */
static
bool is_emcc(void) {
Expand All @@ -194,9 +200,10 @@ bool is_msvc(void) {
return is_compiler("cl.exe", 0);
}

/* Is current compiler mingw */
static
bool is_mingw(void) {
return is_compiler("gcc", 0) && is_msys();
return is_gcc() && is_msys();
}

/* Is binary a dylib */
Expand Down Expand Up @@ -256,7 +263,11 @@ void init(
driver->set_attr_string("cpp-standard", "c++0x");
}
if (!driver->get_attr("c-standard")) {
driver->set_attr_string("c-standard", "c99");
if (is_gcc() || is_clang(BAKE_SRC_LANG_C)) {
driver->set_attr_string("c-standard", "gnu99");
} else {
driver->set_attr_string("c-standard", "c99");
}
}
if (!driver->get_attr("precompile-header")) {
#ifndef _WIN32
Expand Down

0 comments on commit 56a0cfc

Please sign in to comment.