diff --git a/resources/testproject/hello_world.c3 b/resources/testproject/hello_world.c3 index 7f1437c22..0909b0113 100644 --- a/resources/testproject/hello_world.c3 +++ b/resources/testproject/hello_world.c3 @@ -11,5 +11,7 @@ fn int main() printf("Hello World!\n"); bar::test(); printf("Hello double: %d\n", test_doubler(11)); + if ($feature(ABCD)) io::printn("ABCD"); + return 0; } \ No newline at end of file diff --git a/resources/testproject/project.json b/resources/testproject/project.json index 821bba493..68e21e6e3 100644 --- a/resources/testproject/project.json +++ b/resources/testproject/project.json @@ -14,6 +14,8 @@ // libraries to use "dependencies": [], + "features": ["ABCD"], + // c compiler "cc": "cc", // c sources diff --git a/src/build/project.c b/src/build/project.c index eb01509f2..b16f7aa6e 100644 --- a/src/build/project.c +++ b/src/build/project.c @@ -41,6 +41,7 @@ const char *project_default_keys[] = { "winsdk", "x86-stack-struct-return", "x86vec", + "features" }; const int project_default_keys_count = sizeof(project_default_keys) / sizeof(char*); @@ -86,6 +87,7 @@ const char* project_target_keys[] = { "winsdk", "x86-stack-struct-return", "x86vec", + "features", }; const int project_target_keys_count = sizeof(project_target_keys) / sizeof(char*); @@ -357,6 +359,18 @@ static void load_into_build_target(JSONObject *json, const char *type, BuildTarg int fpmath = get_valid_string_setting(json, "fp-math", type, fp_math, 0, 3, "strict, relaxed, fast"); if (fpmath > -1) target->feature.fp_math = fpmath; + const char **features = get_valid_array(json, "features", type, false); + if (features) + { + FOREACH_BEGIN(const char *feature, features) + if (!str_is_valid_constant(feature)) + { + error_exit("Error reading 'features': '%s' is not a valid feature name.", feature); + } + vec_add(target->feature_list, feature); + FOREACH_END(); + } + // x86vec int x86vec = get_valid_string_setting(json, "x86vec", type, x86_vector_capability, 0, 6, "none, native, mmx, sse, avx or avx512"); if (x86vec > -1) target->feature.x86_vector_capability = x86vec; diff --git a/src/version.h b/src/version.h index bd9375475..f659bd71f 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.645" \ No newline at end of file +#define COMPILER_VERSION "0.4.646" \ No newline at end of file