PRODUCT : Borland C++ NUMBER : 1019 VERSION : 3.1 OS : ALL DATE : October 19, 1993 PAGE : 1/2 TITLE : Using COMDEFs with v3.x of BC++ COMDEFs are an extension to C. They enable a programmer to link modules containing duplicate uninitialized global variables that are not declared as extern and not get any duplicate symbol errors. Variables used in this manner are also known as communal variables. For example, FOO.C: int i; BAR.C: int i; main() test() { { } } If we have 'OPTIONS|COMPILER|ADVANCED CODE GENERATION|OPTIONS|GENERATE COMDEFs' enabled, then the above code will generate only one instance of i, and the modules will link together with no errors. With COMDEFs disabled, one of the "int i;" declarations needs to have the keyword extern in order to get past the linker. Additionally, if one of the declarations for i is initialized (such as "int i = 1;"), then COMDEFs will not apply for i, and duplicate symbols will result if declarations of i in other modules are not declared as extern. Borland has COMDEFs disabled by default since they are an extension to C and are not part of the ANSI C standard. (Several PC Compiers have COMDEFs enabled by default). According to ANSI, the above code is illegal. However, with Borland's Generate COMDEFs option enabled, the above code is accepted by the linker. COMDEFs are not supported under C++ because uninitialized global variables are treated in C++ as though they were initialized to zero. (All global objects have storage class static, and all uninitialized static variables are implicitly initialized to zero.) PRODUCT : Borland C++ NUMBER : 1019 VERSION : 3.1 OS : ALL DATE : October 19, 1993 PAGE : 2/2 TITLE : Using COMDEFs with v3.x of BC++. For more information on C++ uninitialized global variables, see sections 3.5 and 8.4 in Ellis & Stroustrup's The Annotated C++ Reference Manual (1990, Addison-Wesley). The most likely problem that one would run into with communal variables is the error message ERROR: defined in module is duplicated in module If you must use C++, you may not use COMDEFs because C++ does not support them. Use the keyword 'extern' (as explained above) instead of using COMDEFs and multiple declarations. If you don't need to use C++ and still want to use COMDEFs, switch to using C. DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.