From e7c17648ba88d61ff7c592a82757015eacd33342 Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 22 Jun 2024 00:01:14 +0000 Subject: [PATCH] added function to get compiler version git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@414 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Client/client.c | 7 +++++-- Library/dataworks.c | 21 +++++++++++++++++++++ Library/dataworks.h | 8 ++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Client/client.c b/Client/client.c index 5e412fc..cec322c 100644 --- a/Client/client.c +++ b/Client/client.c @@ -145,8 +145,11 @@ int main(int argc, char** argv) { } if(banner) { printf("DataWorks version %s %s %s\n", dataworks_get_version(), dataworks_get_compile_date(), dataworks_get_platform()); - printf("Using Yacc: %s\n", dataworks_get_yacc_version()); - printf(" Lex: %s\n", dataworks_get_lex_version()); + char* comp = dataworks_get_compiler(); + printf(" Using Yacc: %s\n", dataworks_get_yacc_version()); + printf(" Lex: %s\n", dataworks_get_lex_version()); + printf("Compiled using: %s\n", comp); + free(comp); if(dataworks_get_endian() == 'L') { printf("This system is little-endian.\n"); } else { diff --git a/Library/dataworks.c b/Library/dataworks.c index b82a39e..8b889bc 100644 --- a/Library/dataworks.c +++ b/Library/dataworks.c @@ -33,6 +33,8 @@ #include #include +#include +#include const char* dataworks_version = "0.1.1"; const char* dataworks_compile_date = __DATE__; @@ -94,6 +96,25 @@ const char* dataworks_get_copyright(void) { return dataworks_copyright; } int yywrap() { return 1; } +char* dataworks_get_compiler(void) { + char* ver = malloc(513); + memset(ver, 0, 513); +#if defined(__WATCOMC__) + sprintf(ver, "Open Watcom %d.%d", __WATCOMC__ / 100, __WATCOMC__ % 100); +#elif defined(__clang__) + sprintf(ver, "%s", __VERSION__); +#elif defined(__PCC__) + sprintf(ver, "%s", __VERSION__); +#elif defined(__VBCC__) + sprintf(ver, "VBCC"); +#elif defined(__GNUC__) + sprintf(ver, "GCC %s", __VERSION__); +#else + sprintf(ver, "Unsupported compiler"); +#endif + return ver; +} + int yyerror(const char* err) { fprintf(stderr, "Parser error: %s\n", err); return 0; diff --git a/Library/dataworks.h b/Library/dataworks.h index e16ab52..bf23669 100644 --- a/Library/dataworks.h +++ b/Library/dataworks.h @@ -69,6 +69,14 @@ const char* dataworks_get_yacc_version(void); */ const char* dataworks_get_lex_version(void); +/** + * @~english + * @brief Get the compiler which was used to compile DataWorks + * @return Compiler which was used to compile DataWorks + * + */ +char* dataworks_get_compiler(void); + /** * @~english * @brief Get the compilation date of DataWorks -- 2.43.0