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).
This commit is contained in:
@@ -409,7 +409,7 @@ static void options_parse(int argc, const char **argv)
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
else if(version) {
|
else if(version) {
|
||||||
printf("%s\n", cycles_version_number().c_str());
|
printf("%s\n", CYCLES_VERSION_STRING);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
else if(help || options.filepath == "") {
|
else if(help || options.filepath == "") {
|
||||||
|
@@ -27,18 +27,13 @@ CCL_NAMESPACE_BEGIN
|
|||||||
#define CYCLES_VERSION_MINOR 7
|
#define CYCLES_VERSION_MINOR 7
|
||||||
#define CYCLES_VERSION_PATCH 0
|
#define CYCLES_VERSION_PATCH 0
|
||||||
|
|
||||||
/* Create string number, like "1.7.0" */
|
#define CYCLES_MAKE_VERSION_STRING2(a,b,c) #a "." #b "." #c
|
||||||
string cycles_version_number()
|
#define CYCLES_MAKE_VERSION_STRING(a,b,c) CYCLES_MAKE_VERSION_STRING2(a,b,c)
|
||||||
{
|
#define CYCLES_VERSION_STRING \
|
||||||
stringstream ss;
|
CYCLES_MAKE_VERSION_STRING(CYCLES_VERSION_MAJOR, \
|
||||||
ss << CYCLES_VERSION_MAJOR << "."
|
CYCLES_VERSION_MINOR, \
|
||||||
<< CYCLES_VERSION_MINOR << "."
|
CYCLES_VERSION_PATCH)
|
||||||
<< CYCLES_VERSION_PATCH;
|
|
||||||
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
CCL_NAMESPACE_END
|
CCL_NAMESPACE_END
|
||||||
|
|
||||||
#endif /* __UTIL_VERSION_H__ */
|
#endif /* __UTIL_VERSION_H__ */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user