Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Global (as in unit) variable supposedly referencing variable within DLL?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Dec 9, 2016 11:32 AM Last Post By: Peter Below Threads: [ Previous | Next ]
Toby Dobbs

Posts: 77
Registered: 9/24/16
Global (as in unit) variable supposedly referencing variable within DLL?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2016 4:33 AM
Hi,

I am working with a DLL to control a piece of hardware using an interface with Delphi. There is a variable within the example program (a Delphi application) which reads...

var
  buffersx,                         // buffersx located in SWDLL
  buffers,                          // buffers are created on our stack
  buffers1,buffers2,buffers3,buffers4,
  buffers5,buffers6,buffers7,buffers8: aptype;


The first line (buffersx,) confuses me. If the variable is declared in the current unit how can it be located in SWDLL?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Global (as in unit) variable supposedly referencing variable withinDLL?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2016 11:31 AM   in response to: Toby Dobbs in response to: Toby Dobbs
Toby wrote:

The first line (buffersx,) confuses me. If the variable is declared
in the current unit how can it be located in SWDLL?

It is not. That code is declaring a local variable named 'buffersx' of type
'aptype'. The comment is misleading.

--
Remy Lebeau (TeamB)
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Global (as in unit) variable supposedly referencing variable within DLL?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2016 11:32 AM   in response to: Toby Dobbs in response to: Toby Dobbs
Toby Dobbs wrote:

Hi,

I am working with a DLL to control a piece of hardware using an
interface with Delphi. There is a variable within the example program
(a Delphi application) which reads...

var
  buffersx,                         // buffersx located in SWDLL
  buffers,                          // buffers are created on our
stack   buffers1,buffers2,buffers3,buffers4,
  buffers5,buffers6,buffers7,buffers8: aptype;


The first line (buffersx,) confuses me. If the variable is declared
in the current unit how can it be located in SWDLL?

Oh, it cannot be, but if aptype is a pointer type the code may set the
variable to the address of the buffer in the DLL somewhere, and then
you can indeed access it directly.

--
Peter Below
TeamB

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02