Enhance downward compatibility for DLLs that contains C++ functions with parameters of default values
Original Publication Date: 2005-Jul-18
Included in the Prior Art Database: 2005-Jul-18
Supporting default parameter values for functions and class methods is a convenient feature of the C++ language. However, this feature may cause potential downward compatibility problems if applied without careful planning forethought. This paper describes the cause of this problem potential compatibility issues and proposes a solution to resolve them.
Enhance downward compatibility for DLLs that contains C ++ functions with parameters of default values
Definition: Downward compatibility - Assume the required programming guideline and restrictions are followed, the support enables programmer to develop Dynamic Linked Library (DLL) of higher release levels that can be used by applications developed with the same DLL with lower release levels.
Body: Different from the C programming language, the C++ language allows functions or class methods to be defined with default parameter values. These functions will use the default values for the parameters if the callers do not supply one.
The concept of default parameter values was considered as a convenient feature of C++; nevertheless, it may cause potential downward compatibility problems if applied without careful forethought. For instance, we have a function prototype:
static void initialize();
Assume this function was shipped in a product, packaged as a DLL, and customers develop their applications using this DLL. Now in the next revision of the product, an enhancement is made whereby a storage management controller is added. This change is made in such a way that will require a storage manager passed into every function . If such a storage manager was not supplied by the caller, a predefined system storage manager will be used by default. The original function interface would be modified as follows:
Static void initialize(StorageManager& object = StorageManager::DefaultStorageManager());
If the DLL is shipped with this new function, none of the existing applications compiled with the old DLL will work, because the DLL no longer contains the entry point for "static void initialize()". In other words, the new DLL is not downward compatible with the existing applications. However, the source code for the existing application is still valid, and if it is recompiled with the new DLL without any other modification, the application will work....