HELP PLEASE EXTERNAL VARIABLE REFERENCES IN WATCOM 
Author Message
 HELP PLEASE EXTERNAL VARIABLE REFERENCES IN WATCOM

I'm using Watcom v10.5 doing some DOS Devolopment (DOS4GW)

Pure C
Pure ASM

Whenever I try using external Variables that were declared in the C prog
in my assembly code.  When I try to link the linked allways returns
errors, that the variables are undefined references.

If you could help me out I would really appreciate it.

Thanks in advance.



Wed, 23 Dec 1998 03:00:00 GMT  
 HELP PLEASE EXTERNAL VARIABLE REFERENCES IN WATCOM

Quote:

>I'm using Watcom v10.5 doing some DOS Devolopment (DOS4GW)
>Pure C
>Pure ASM
>Whenever I try using external Variables that were declared in the C prog
>in my assembly code.  When I try to link the linked allways returns
>errors, that the variables are undefined references.
>If you could help me out I would really appreciate it.
>Thanks in advance.

WASM isn't known for its copious documentation, but a little hacking
can go a long way when you're trying to surmount difficulties like
this.  The "no-brainer" method of writing a C stub program that has
the same interface as your .ASM code and then disassembling the
resulting .OBJ file (WDISASM -a stub.obj > stub.asm) gives you a .ASM
file with the correct interfacing information already embedded.  It
even works for interfacing with C++ programs.  What you will likely
discover is that you neglected to put the underscore in front of
variable names and after function names (assuming you are using the
register calling convention) in your EXTRN statements and in your
PUBLIC statements.
There will be other humps to get over (like how to replace the REPT statement),
but I have found that you can get over them, usually with only minimal
experimentation.


Wed, 23 Dec 1998 03:00:00 GMT  
 HELP PLEASE EXTERNAL VARIABLE REFERENCES IN WATCOM

Quote:

> I'm using Watcom v10.5 doing some DOS Devolopment (DOS4GW)

> Pure C
> Pure ASM

> Whenever I try using external Variables that were declared in the C prog
> in my assembly code.  When I try to link the linked allways returns
> errors, that the variables are undefined references.

This is because the WATCOM C/C++ compiler appends (or is it prepends?  I
can't remember which) an underscore on all global "C" symbols.  By
default nothing is done to assembly symbols.  So to use one languages
symbols in the other, WATCOM requires that you declare the name
modification method along with each variable using the #pragma
directive.

All this information can be looked up in the online help.  For more
information you can consult the WATCOM C/C++ FAQ at the following URL:

    http://www.geocities.com/SiliconValley/9498/watfaq.txt

--
Paul Hsieh

http://www.geocities.com/SiliconValley/9498
Graphics Programmer
Chromatic Research

What I say and what my company says are not always the same thing



Wed, 23 Dec 1998 03:00:00 GMT  
 HELP PLEASE EXTERNAL VARIABLE REFERENCES IN WATCOM

Quote:


> > I'm using Watcom v10.5 doing some DOS Devolopment (DOS4GW)

> > Pure C
> > Pure ASM

> > Whenever I try using external Variables that were declared in the C prog
> > in my assembly code.  When I try to link the linked allways returns
> > errors, that the variables are undefined references.

> This is because the WATCOM C/C++ compiler appends (or is it prepends?  I
> can't remember which) an underscore on all global "C" symbols.  By
> default nothing is done to assembly symbols.  So to use one languages
> symbols in the other, WATCOM requires that you declare the name
> modification method along with each variable using the #pragma
> directive.

> All this information can be looked up in the online help.  For more
> information you can consult the WATCOM C/C++ FAQ at the following URL:

>     http://www.geocities.com/SiliconValley/9498/watfaq.txt

> --
> Paul Hsieh

> http://www.geocities.com/SiliconValley/9498
> Graphics Programmer
> Chromatic Research

> What I say and what my company says are not always the same thing

I think I have a bum copy of Watcom 10.5, I had to boot clean nothing
loaded at all except environment variables, and finally it would compile
and link properly.  The only problem is since I bought Watcom I haven't
seen a 10.5 patch anywhere and they just want to sell me the upgrade to
10.6.  But here is another question.  I got my external variables to
link properly but whenever I want to access and array for gdoublebuffer
I get GPF's and dumped back to dos.  What would be the best way to say
find an offset and then add the offset to base offset of the array and
find the value stored at gdoublebuffer[offset].  I need all the
registers including esi and edi for the main rendering loop in order to
keep my speed up, so I can't point them at the array.  I'm pretty sure
that I have coded it properly but this is just another one of those
watcom bugz.  I can do it fine in Borland C++ but I don't like their
protected mode interface.

Thanks



Thu, 24 Dec 1998 03:00:00 GMT  
 HELP PLEASE EXTERNAL VARIABLE REFERENCES IN WATCOM


Quote:
>I think I have a bum copy of Watcom 10.5, I had to boot clean nothing
>loaded at all except environment variables, and finally it would compile
>and link properly.  The only problem is since I bought Watcom I haven't
>seen a 10.5 patch anywhere and they just want to sell me the upgrade to
>10.6.

Er, the 10.5 -> 10.6 upgrade is free, right?
It says so on the Watcom web site (www.powersoft.com), anyway.

Frank.



Sun, 27 Dec 1998 03:00:00 GMT  
 HELP PLEASE EXTERNAL VARIABLE REFERENCES IN WATCOM

: I'm using Watcom v10.5 doing some DOS Devolopment (DOS4GW)

: Pure C
: Pure ASM

: Whenever I try using external Variables that were declared in the C prog
: in my assembly code.  When I try to link the linked allways returns
: errors, that the variables are undefined references.

First thing to do is check if there are underscores either in front of or
behind the variables in the link error message.

Then do a hex dump of the .obj file that has the variable in it, and look
for the names. See if they match up underscore-wise.

Watcom (when using the default register parameter passing) doesn't conform
to the usual format (_varname). You may have to declare them explicitly as
type SYSCALL and add the underscore yourself. I know you have to with
functions, but I'm not 100% sure on variables. Use something like:

                extern SYSCALL blahblah:dword

assuming you're using MASM or the like.

All the best.
Adrian Thewlis



Wed, 06 Jan 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Watcom / WASM problem with external variables

2. Please Please Help - Clarion External Report Wrtter

3. HELP! Linking Watcom w/ external asm

4. Watcom C/C++ Gurus: Please Help.

5. Watcom C/C++ and WASM... Please help again :)

6. Watcom Fortran - Help Please

7. Please Help on Libmaker/external DLLs

8. Help Please - Linking error (unresolved externals)

9. TclKit and external packages [Help please!]

10. Please Help: External Event Loop & Win95

11. Please help! - Launch an external program

12. Please help - launch a external program

 

 
Powered by phpBB® Forum Software