Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Visual C++ version numbers have a comma in them instead of a dot

I have seen that my Visual C++ projects have the following declarations that use COMMAS instead of DOTS for versions:

#define FILEVER        11,0,2,0
#define PRODUCTVER     11,0,2,0
#define STRFILEVER     "11, 0, 2, 0\0"
#define STRPRODUCTVER  "11, 0, 2, 0\0"

The MS article here also has the same values with commas (actually the above declarations are based on that article). Why are we using COMMAS here? When I open the compiled file properties, I see FileVersion as 11.0.2.0 but ProductVersion as 11,0,2,0 - for which my QA friends say that its a bug :). Is there some standard or maybe some internal mechanism that I am missing?

like image 637
A9S6 Avatar asked Oct 22 '12 07:10

A9S6


1 Answers

In the first two definitions because Microsoft resource file syntax calls for commas. For the later two definitions the Microsoft convention sticks to commas there too. Microsoft wants to differ, probably.

The file version is taken from the non-string variant and gets printed with dots in file explorer. The product version gets taken from the string. You could probably write the string with dots yourself. It's a string, it shouldn't matter. But you'll have to edit the .rc file manually—Visual Studio will write commas.

As for the first two definitions, I can see reason for choosing commas in general C++. If you had 11.0.2.0, it would be syntax error in about any context and the only thing you could do is convert it to string with the # operator. But with commas, you can expand it to definition of array or structure. Like int version[] = { 11,0,2,0 };. That's useful if you want to have version check in code.

like image 156
Jan Hudec Avatar answered Oct 30 '22 20:10

Jan Hudec