hd7q@hudson.acc.virginia.edu (das himadri) (07/11/89)
I am trying to port Pascal code which compiles with a standard Pascal compiler on a Prime 9955 machine to a PC running MS DOS. The code is fairly big, about 300 kbytes and involves procedures using other procedures as parameters. I tried Turbo Pascal 5.0 for which the code had to be broken up into units of less than 64 kbytes. I am having problems while trying to use in one unit a procedure available in another unit when calling this procedure involves passing a complex data type between the two procedures. To elaborate a bit further, there is no problem if a character or integer or real is being passed between two units but if a string or a pointer to a record or an array of pointers to records needs to be passed between the two units then it doesn't work but gives a type mismatch error during compilation. This type mismatch refers to the complex data structure that needs to be passed between the two units even though they have been declared in both units. Has anybody had similar problems when dealing with large code in Turbo Pascal? Is there a way around this? How about other Pascal compilers for MS DOS systems which are closer to standard Pascal and can handle the 64 Kbyte limit as well as allow procedures to take other procedures as parameters? Any information regarding other Pascal compilers and their availability would be greatly appreciated. Would also welcome suggestions about how to use Turbo Pascal for what I trying to do. Thanks! -- ***************************************************************************** * Himadri Das * Life is so Beautiful! * * hd7q@virginia.edu * Ain't it? * *****************************************************************************
maine@elxsi.dfrf.nasa.gov (Richard Maine) (07/11/89)
In article <1723@hudson.acc.virginia.edu> hd7q@hudson.acc.virginia.edu (das himadri) writes: > I am trying to port Pascal code which compiles with a standard Pascal > compiler on a Prime 9955 machine to a PC running MS DOS. The code > .... > procedures as parameters. I tried Turbo Pascal 5.0 for which the code > had to be broken up into units of less than 64 kbytes. I am having > problems while trying to use in one unit a procedure available in another > unit when calling this procedure involves passing a complex data type > between the two procedures. To elaborate a bit further, there is no > problem if a character or integer or real is being passed between > two units but if a string or a pointer to a record or an array of pointers > to records needs to be passed between the two units then it doesn't > work but gives a type mismatch error during compilation. This type > mismatch refers to the complex data structure that needs to be passed > between the two units even though they have been declared in both units. If you are declaring the structure in both units then that is the problem. The two separate declarations are not compatable, even though they look identical. In this regard, Turbo is actually hewing fairly closely to the principles of the standard (extended to deal with the separate units) in that the standard generally does not regard two separate declarations to be compatable, even if they appear identical. The solution is to declare the structure in the interface portion of one of the units and have the other unit "use" the first one. Then the second unit will inherit the type declaration of the first one insead of having its own incompatable type. -- Richard Maine maine@elxsi.dfrf.nasa.gov [130.134.1.1] (Outside mail won't get to altair.dfrf.nasa.gov, so don't bother trying).
jeff@carroll1.UUCP (Jeff Bartig) (07/11/89)
In article <1723@hudson.acc.virginia.edu> hd7q@hudson.acc.Virginia.EDU (das himadri) writes: > >...... I am having >problems while trying to use in one unit a procedure available in another >unit when calling this procedure involves passing a complex data type >between the two procedures. To elaborate a bit further, there is no >problem if a character or integer or real is being passed between >two units but if a string or a pointer to a record or an array of pointers >to records needs to be passed between the two units then it doesn't >work but gives a type mismatch error during compilation. This type >mismatch refers to the complex data structure that needs to be passed >between the two units even though they have been declared in both units. To get around the type mismatch error, create a new unit called "defs.pas". Place your type definitions in this unit. Example: UNIT Defs; INTERFACE TYPE CDT = ARRAY[1..100] of INTEGER; {complex data type} IMPLEMENTATION END. Now add "Defs" to the USES line in the UNITs that use this type. Since both procedures will now be using the same TYPE definition, instead of two separate (even though equal) definitions, you shouldn't get the type mismatch error. Hope this helps! Jeff ____________________________________________________________ | Jeff Bartig, Carroll College | "The sooner you fall | | jeff@carroll1.cc.edu | behind, the more time you | | uunet!marque!carroll1!jeff | have to catch up." | ------------------------------------------------------------
px@unl.fctunl.rccn.pt (Joaquim Baptista (pxQuim)) (07/11/89)
In article <MAINE.89Jul10133525@altair.dfrf.nasa.gov> maine@elxsi.dfrf.nasa.gov (Richard Maine) writes, replying to article <1723@hudson.acc.virginia.edu> by hd7q@hudson.acc.virginia.edu (das himadri): > The solution is to declare the structure in the interface portion of > one of the units and have the other unit "use" the first one. Then > the second unit will inherit the type declaration of the first one > instead of having its own incompatable type. As a matter of style, I prefer to declare a third unit which contains only declarations and is imported by the units who need them. This conforms with the principle of the "Abstract data types" and usually makes the interactions among the units clearer. -- -------- Joaquim Manuel Soares Baptista | BITNET/Internet: px@fctunl.rccn.pt Centro de Inteligencia Artificial | UUCP: px@unl.uucp Uninova | ARPA: px%fctunl.rccn.pt@mitvma.mit.edu Fac. de Ciencias e Tecnologia/UNL | PSI/VMS: PSI%(+2680)005010310::PX 2825 Monte de Caparica | Fax: (+351) (1) 295 4461 PORTUGAL | Sound: (+351) (1) 295 4464 ext. 1360
leonard@bucket.UUCP (Leonard Erickson) (07/12/89)
hd7q@hudson.acc.virginia.edu (das himadri) writes:
<... I tried Turbo Pascal 5.0 for which the code
<had to be broken up into units of less than 64 kbytes. I am having
<problems while trying to use in one unit a procedure available in another
<unit when calling this procedure involves passing a complex data type
<between the two procedures. To elaborate a bit further, there is no
<problem if a character or integer or real is being passed between
<two units but if a string or a pointer to a record or an array of pointers
<to records needs to be passed between the two units then it doesn't
<work but gives a type mismatch error during compilation. This type
<mismatch refers to the complex data structure that needs to be passed
<between the two units even though they have been declared in both units.
If you declare a type in two seperate units, you have declared two
*different* types! Even if the declarations are identical. Check the
discussion of types on pages 36 thru 38 of the Reference Guide.
You need to declare the type in one unit and have the other unit
*use* that unit.
--
Leonard Erickson ...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I'm all in favor of keeping dangerous weapons out of the hands of fools.
Let's start with typewriters." -- Solomon Short