From d7c79c66018d50cb10012be536cf7f1b108e2a9f Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Sun, 28 Aug 2022 12:43:01 -0400 Subject: [PATCH] Simplify and make work without warnings --- ZSharp/builtin.h | 16 ++++++++++++---- examples/console_application.zs | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 examples/console_application.zs diff --git a/ZSharp/builtin.h b/ZSharp/builtin.h index c66f1cd..72f0669 100644 --- a/ZSharp/builtin.h +++ b/ZSharp/builtin.h @@ -1,6 +1,14 @@ #ifndef BUILTIN_H #define BUILTIN_H +#if defined(__unix__) +#define UNIX true +#define WINDOWS false +#elif defined(_MSC_VER) +#define UNIX false +#define WINDOWS true +#endif + #include #include #include @@ -470,10 +478,10 @@ boost::any ZSFunction(const string& name, const vector& args) } else if (name == "ZS.System.Command"){ string command = StringRaw(AnyAsString(args.at(0))); - int command_len = command.length(); - char command_char_arr[command_len + 1]; - strcpy(command_char_arr, command.c_str()); // string into char arr - int k = system(command_char_arr); + //int command_len = command.length(); + //char* command_char_arr=new char[command_len + 1]; + //strcpy(command_char_arr, command.c_str()); // string into char arr + int k = system(command.c_str()); } else LogWarning("ZS function \'" + name + "\' does not exist."); diff --git a/examples/console_application.zs b/examples/console_application.zs new file mode 100644 index 0000000..07d48b9 --- /dev/null +++ b/examples/console_application.zs @@ -0,0 +1,5 @@ +func Main() +{ + Printl("this is a test:") + ZS.System.Command("cls") +} \ No newline at end of file