hello, how exactly define var DD 10 DUP(0) as extern(the var ist in a nother obj) ?
I tryed extern var:DWORD but that cased an not resolved symbol.

Greets BBB
Posted on 2003-09-07 01:22:19 by Bubu-Boy
do you mean a .data? section if so put (?) instead of (0)
Posted on 2003-09-07 01:39:19 by devilsclaw
??????
but how ?
:confused:
.data
extern var dword 100 dup (?)

or extern var[100]:DWORD


???? - but nochting works.

it is possible to give an example ?
Posted on 2003-09-07 01:52:02 by Bubu-Boy
.data
BLANK db 64 dup(0) ; this will make it part of the exe


.data?
BLANK db 64 dup(?) ; this will use memory instead

.data? is a diff section type then .data
Posted on 2003-09-07 02:00:07 by devilsclaw
You cannot provide a count parameter for EXTERN. It is not necessary as it is only a label, you cannot specify how much memory to set aside in another OBJ file. The supplying of counts is only used to set aside space for the buffer, it is not necessary when accessing it. You would define your externally referenced variable without the [] and access it normally as the other object file has already set aside the memory.

extern var:DWORD

mov eax,var[16]
Posted on 2003-09-07 02:02:22 by donkey
hmm, it doesnt work.
the linker says _var unresolved external symbol....
there ist a "_" before the variable...
Posted on 2003-09-07 02:24:50 by Bubu-Boy
since donkey understands what you are asking... do as he tells you...
Posted on 2003-09-07 02:26:23 by devilsclaw
Yes, you must decorate the name with an underscore. I had neglected to include that point. You must also declare the variable as public in your other obj:

PUBLIC var

var DWORD 256 DUP (?)
Posted on 2003-09-07 02:47:28 by donkey
mega thanks ! :alright:
Posted on 2003-09-07 02:52:17 by Bubu-Boy
I'm sorry Bubu boy, I was thinking about linking with GoLink, with MS link I think it will automatically decorate the variable so you don't use the underscore, it is like my first example, don't forget PUBLIC.
Posted on 2003-09-07 03:04:07 by donkey
thank you daddy i wount forget !
Posted on 2003-09-07 03:25:00 by Bubu-Boy
You can use EXTERNDEF instead of PUBLIC

From masm32.hlp


The EXTERNDEF directive tells the assembler that one or more
variables, symbols, data structures, or labels are defined in
other modules. The behavior of the EXTERNDEF directive is
determined by its context:


* If <name> is used in the current module but is not defined,
<name> is made external.
* If <name> is defined in the current module, it is made
PUBLIC.
* If <name> is neither used nor defined, the directive is
ignored.

The EXTERNDEF directive allows you to put global data declarations
in an include file without forcing the linker to pull in unneeded
modules. Usually, you define <name> in one module and put the

EXTERNDEF directive in a file that is included in all program
modules. The PROTO directive automatically generates an EXTERNDEF
for its related procedure.

EXTERN is a less flexible version of EXTERNDEF. It declares
<name> as external whether or not it is used in the module.
EXTRN is a synonym for EXTERN and is included for compatibility
with previous versions of the assembler.

With the EXTERN directive, <name> can be followed by (altID),

which allows the linker to select an alternate resolution for
<name>. This is useful when creating library files.

So you can put EXTERNDEF Var:DWORD into your files and the assembler decides if var is extern or decalred in this file. Then you can move a variable from a module to another without changing EXTERNDEF definitions
Posted on 2003-09-07 03:48:26 by greenant
Thanks friend!

I would like to call an extern function:

c++:


char temp;
void public TheBigBu(HAWND hwnd)
{

printf("BUBUUUUUUUUUUUUUUUU");
wsprintf(temp, "%i", hwnd)
}




1. i cant acess the temp variable.
2. cant declare the extern function iwth its parameter
please help. I tryed everything.



greets
Posted on 2003-09-07 16:01:24 by Bubu-Boy
i dont know what kind of obj your calling on but if its a lib or a dll

http://elicz.cjb.net

has a nice macro file that lets you call on libs and dll with out making protos

if your calling on a lib or a dll and dont want to use his macros then you will have to make a proto for what your trying to call on

example:
TheBigBu PROTO :DWORD,:DWORD
Posted on 2003-09-07 16:06:39 by devilsclaw
the extern is usually for using global vars which are declaired in some file to use in another file.
exmaple:

x.cpp
------
int lala; // eclaired as global!!
void main()
{
lala=5;
}

============
============

y.cpp
-----
extern int lala;

void bla()
{
lala=6;
}

got it?
Posted on 2003-09-07 16:58:22 by wizzra
How I can acess the function and the variable with MASM ?

Greets BB
Posted on 2003-09-08 12:51:02 by Bubu-Boy