Technical Notes Database TN136D.txt TYPE MISMATCH ERROR COMPILING UNITS Category :Pascal Platform :All Product :Turbo Pascal 4.0+ Description: Q. Why is the compiler reporting "Type Mismatch Error" when I have declared every variable? A. The most common error of this type is caused by duplicated type definitions. First some background on how Turbo Pascal 4.0+ works. All identifiers (procedures, functions, types, variables, constants) are handled by appending the module name to the front of them (ie., ProgramName.identifier or UnitName.Identifier). Now, if you have a type, MYTYPE, in Unit MyUnit and also in MyProgram you have the following TWO DIFFERENT Types : MyUnit.MYTYPE and MyProgram.MyType. Please notice that by no means does "MyUnit.MYTPYE" equal "MyProgram.MYTYPE". The actual contents of MyType does not even enter into this discussion and Turbo Pascal only looks at the Type name. The Solution? Declare types only in the interface section of the original unit AND NOWHERE ELSE!. Alternatively, declare variables with the file type name (ie., if you want to pass a variable of MYTYPE to the unit MyUnit, declare the variable: var MyVar : MyUnit.MYTYPE;). Reference: 7/16/98 4:35:29 PM
Last Modified: 01-SEP-99