aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGertjan van den Burg <burg@ese.eur.nl>2017-01-02 10:10:26 +0100
committerGertjan van den Burg <burg@ese.eur.nl>2017-01-02 10:10:26 +0100
commit04bbfeee114140829271ff508f59993ed90f9086 (patch)
treea14871ff6db141409d39a262df3eb3582d993e18
parentalways run coverage when making docs (diff)
downloadgensvm-04bbfeee114140829271ff508f59993ed90f9086.tar.gz
gensvm-04bbfeee114140829271ff508f59993ed90f9086.zip
fix for string version
-rw-r--r--include/gensvm_globals.h14
-rw-r--r--src/GenSVMgrid.c2
-rw-r--r--src/GenSVMtraintest.c2
-rw-r--r--src/gensvm_io.c2
-rw-r--r--tests/src/test_gensvm_io.c2
5 files changed, 18 insertions, 4 deletions
diff --git a/include/gensvm_globals.h b/include/gensvm_globals.h
index 1aca458..83eb41f 100644
--- a/include/gensvm_globals.h
+++ b/include/gensvm_globals.h
@@ -120,4 +120,18 @@ typedef enum {
*/
#define matrix_mul(M, cols, i, j, val) M[(i)*(cols)+j] *= val
+// ######################### Other Macros ################################# //
+
+// from: http://stackoverflow.com/q/195975/
+
+#define GENSVM_QUOTE(name) #name
+#define GENSVM_STRING(macro) GENSVM_QUOTE(macro)
+
+#ifndef VERSION
+ #define VERSION 0.0.0
+#endif
+
+#define VERSION_STRING GENSVM_STRING(VERSION)
+
+
#endif
diff --git a/src/GenSVMgrid.c b/src/GenSVMgrid.c
index 6f5843d..3907272 100644
--- a/src/GenSVMgrid.c
+++ b/src/GenSVMgrid.c
@@ -68,7 +68,7 @@ void read_grid_from_file(char *input_filename, struct GenGrid *grid);
*/
void exit_with_help(char **argv)
{
- printf("This is GenSVM, version %1.1f.\n", VERSION);
+ printf("This is GenSVM, version %s.\n", VERSION_STRING);
printf("Copyright (C) 2016, G.J.J. van den Burg.\n");
printf("This program is free software, see the LICENSE file "
"for details.\n\n");
diff --git a/src/GenSVMtraintest.c b/src/GenSVMtraintest.c
index f768cd8..0da45ec 100644
--- a/src/GenSVMtraintest.c
+++ b/src/GenSVMtraintest.c
@@ -61,7 +61,7 @@ void parse_command_line(int argc, char **argv, struct GenModel *model,
*/
void exit_with_help(char **argv)
{
- printf("This is GenSVM, version %1.1f.\n", VERSION);
+ printf("This is GenSVM, version %s.\n", VERSION_STRING);
printf("Copyright (C) 2016, G.J.J. van den Burg.\n");
printf("This program is free software, see the LICENSE file "
"for details.\n\n");
diff --git a/src/gensvm_io.c b/src/gensvm_io.c
index 667bc5c..fb513dc 100644
--- a/src/gensvm_io.c
+++ b/src/gensvm_io.c
@@ -509,7 +509,7 @@ void gensvm_write_model(struct GenModel *model, char *output_filename)
gensvm_time_string(timestr);
// Write output to file
- fprintf(fid, "Output file for GenSVM (version %1.1f)\n", VERSION);
+ fprintf(fid, "Output file for GenSVM (version %s)\n", VERSION_STRING);
fprintf(fid, "Generated on: %s\n\n", timestr);
fprintf(fid, "Model:\n");
fprintf(fid, "p = %15.16f\n", model->p);
diff --git a/tests/src/test_gensvm_io.c b/tests/src/test_gensvm_io.c
index 29776d6..ebe826e 100644
--- a/tests/src/test_gensvm_io.c
+++ b/tests/src/test_gensvm_io.c
@@ -654,7 +654,7 @@ char *test_gensvm_write_model()
char buffer[GENSVM_MAX_LINE_LENGTH];
fgets(buffer, GENSVM_MAX_LINE_LENGTH, fid);
- mu_assert(strcmp(buffer, "Output file for GenSVM (version 0.1)\n")
+ mu_assert(strcmp(buffer, "Output file for GenSVM (version 0.1.0)\n")
== 0, "Line doesn't contain expected content (0).\n");
// skip the time line