[Bf-blender-cvs] [bd7e4d2] master: Tweaks to the version string formation

Sergey Sharybin noreply at git.blender.org
Wed Apr 13 09:59:13 CEST 2016


Commit: bd7e4d2a3db3231cde0b25666d3293e20cca8e92
Author: Sergey Sharybin
Date:   Thu Mar 31 09:44:09 2016 +0200
Branches: master
https://developer.blender.org/rBbd7e4d2a3db3231cde0b25666d3293e20cca8e92

Tweaks to the version string formation

Couple of things:

- No need to use string streams to format the version string,
  we can do it at compile time and don't bother with anything
  at runtime.

- Function declaration was wring and would have caused linking
  conflicts in cases when util_version.h was included from
  multiple places.

We should have an utility function to get Cycles version so
applications which are linked to Cycles dynamically can query
the version, but that can't be done as an inlined function in
header and would need to be a function properly exported to a
global symbol table (aka, be implemented in a .cpp file).

===================================================================

M	intern/cycles/app/cycles_standalone.cpp
M	intern/cycles/util/util_version.h

===================================================================

diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp
index 951e8dc..726e9a5 100644
--- a/intern/cycles/app/cycles_standalone.cpp
+++ b/intern/cycles/app/cycles_standalone.cpp
@@ -409,7 +409,7 @@ static void options_parse(int argc, const char **argv)
 		exit(EXIT_SUCCESS);
 	}
 	else if(version) {
-		printf("%s\n", cycles_version_number().c_str());
+		printf("%s\n", CYCLES_VERSION_STRING);
 		exit(EXIT_SUCCESS);
 	}
 	else if(help || options.filepath == "") {
diff --git a/intern/cycles/util/util_version.h b/intern/cycles/util/util_version.h
index 1984741..6591867 100644
--- a/intern/cycles/util/util_version.h
+++ b/intern/cycles/util/util_version.h
@@ -27,18 +27,13 @@ CCL_NAMESPACE_BEGIN
 #define CYCLES_VERSION_MINOR	7
 #define CYCLES_VERSION_PATCH	0
 
-/* Create string number, like "1.7.0" */
-string cycles_version_number()
-{
-	stringstream ss;
-	ss << CYCLES_VERSION_MAJOR << "."
-       << CYCLES_VERSION_MINOR << "."
-       << CYCLES_VERSION_PATCH;
-
-	return ss.str();
-}
+#define CYCLES_MAKE_VERSION_STRING2(a,b,c) #a "." #b "." #c
+#define CYCLES_MAKE_VERSION_STRING(a,b,c) CYCLES_MAKE_VERSION_STRING2(a,b,c)
+#define CYCLES_VERSION_STRING \
+  CYCLES_MAKE_VERSION_STRING(CYCLES_VERSION_MAJOR, \
+                             CYCLES_VERSION_MINOR, \
+                             CYCLES_VERSION_PATCH)
 
 CCL_NAMESPACE_END
 
 #endif /* __UTIL_VERSION_H__ */
-




More information about the Bf-blender-cvs mailing list