Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One method to determine the operating system version during runtime, regardless of whether it is Windows or Linux, without resorting to a conditional compilation statement is to use platform-specific API calls or library functions to retrieve the version information.

In Windows, this can be achieved by calling the GetVersionEx function from the Windows API, which fills a version information structure with data about the current operating system version.

In Linux, this can be achieved by reading the contents of /etc/os-release, which is a file that contains information about the Linux distribution and version.

Alternatively, cross-platform libraries such as Qt might provide a unified way to retrieve the operating system version information, without needing to write platform-specific code.