Article View: comp.lang.modula2
Article #3089Re: Linking XLib into Modula-2 programs
From: Robert L Rast
Date: Wed, 06 Dec 1995 07:38
Date: Wed, 06 Dec 1995 07:38
89 lines
3099 bytes
3099 bytes
In article <114982385wnr@harvey27.demon.co.uk>,
MC / JE Harvey <jeh@harvey27.demon.co.uk> wrote:
>
>I am having difficulties with the XLib Mode X graphics Library. More
>specifically, I am trying to link the XLib object files into a Modula-2
>program, using the Jensen and Partners International TopSpeed
>Implementation of Modula-2 Version 1.17.
>
>I have created a definition file for the object modules, and set the
>compiler up to use the C procedure calling convention, but when I try
>to link the program, the linker gives me several error messages of the
>form:
I've been down this road before with TS 1.17.
What compiler is XLib from?
Are you prepending an underscore on your object names in
the definition modules. Chances are, the objects in the XLib
has them. Also, put a: (*$G-*) in the .def files. This is a
directive to the compiler to not prefix object names with the
module name.
I had problems using the (*$K+*) directive (use C calling convention).
It seems the compiler generated code for the caller to clean the
stack but the parameters were *not* pushed right-to-left. I think
you can get around this by declaring/calling them in reverse order.
Also, if a C function expects a: foo(char * str), or foo(int * nums),
you must declare in the .def module as: foo(str : ADDRESS) or
foo(nums :ADDRESS) and call as: foo(ADR(SomeStr)); / foo(ADR(Numbers)).
This is because M2 passes a hidden parameter - the HIGH value of
an array. You might have to look at disassembled code for
further info (records/structures). Do you have m2dasm.exe?
You might have to extract everything (.obj) out of the library.
I don't think TS 1.17 supports libraries. If you do this, you
will probably have to write .def for each .obj even if a .obj
object is not referenced in your .mod files.
Then just do:
IMPORT somename; (* for linker resolution *)
I did a CS project involving Modula-2, C, and Assembly.
The main program was Modula-2 and was structured as follows:
MAIN
/ |
/ |
Array BSearch -- CInt
(asm) (C) (Mod2)
CInt (C Interface) is a mini-api that allowed some Window module
routines to be called from BSearch (had to provide a trace).
Hope some light has been shed.
Let me know how it goes,
Bob <:*
"Just because it's bad doesn't mean it won't be popular. After
all, it's Microsoft." ___
__ (.x.) __
--rastrl@acsu.buffalo.edu--(,,^\--\-/--/^,,)--www.acsu.buffalo.edu/~rastrl--
Technical Details
Message-ID:
<4a3h8r$j38@azure.acsu.buffalo.edu>Path:
arc1-ca.pugleaf.net!acsu.buffalo.edu!rastrlReferences:
<114982385wnr@harvey27.demon.co.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!acsu.buffalo.edu!rastrl From: rastrl@cs.buffalo.edu (Robert L Rast) Newsgroups: comp.lang.modula2 Subject: Re: Linking XLib into Modula-2 programs Date: 6 Dec 1995 07:38:03 GMT Organization: State University of New York at Buffalo/Computer Science Message-ID: <4a3h8r$j38@azure.acsu.buffalo.edu> References: <114982385wnr@harvey27.demon.co.uk> NNTP-Posting-Host: gagarin.cs.buffalo.edu NNTP-Posting-User: rastrl