What does this Declaration mean? 
Author Message
 What does this Declaration mean?

Hey,

I'm working with some old Pascal/Delphi code.  I have to translate
some stuff into C/C++.  I was wondering what the significance of this
type declaration was:

type
  tAddress = record end;

Would that be equivalent to a C/C++ void pointer or something?  i'm
not really clear on what the tAddress type represents.

Any help appreciated.

Thanks a lot,
Joe.



Mon, 02 Jan 2006 05:59:10 GMT  
 What does this Declaration mean?

Quote:
> I'm working with some old Pascal/Delphi code.  I have to translate
> some stuff into C/C++.  I was wondering what the significance of this
> type declaration was:

> type
>   tAddress = record end;

> Would that be equivalent to a C/C++ void pointer or something?

no, void pointer type is "pointer"

Quote:
> i'm not really clear on what the tAddress type represents.

It represents nothing, and sizeof(taddress) returns 0.
i don't see any use of this type... but I may be wrong.

--
Azarien

[delete the letter v in my e-mail address]

.



Mon, 02 Jan 2006 07:01:26 GMT  
 What does this Declaration mean?

Quote:

> Hey,

> I'm working with some old Pascal/Delphi code.

If it is Delphi code, it is not necessarily old, since Delphi is still
maintained.

Quote:
> I have to translate
> some stuff into C/C++.  I was wondering what the significance of this
> type declaration was:

> type
>   tAddress = record end;
> Would that be equivalent to a C/C++ void pointer or something?  i'm
> not really clear on what the tAddress type represents.

No, no pointer. It is nothing. Absolutely nothing.

The only practical use I can think of is place holder at the end of a
record.

Quote:
> Any help appreciated.

[nothing] or you need to show more related code.

The name tAddress is quite sane, since an address is usually a pointer
without a size of the thing it points to.

So usually something like taddress will be used as a marker to obtain the

of that is simply a void ptr.

So maybe the best translation is taddress = "void".



Mon, 02 Jan 2006 07:10:12 GMT  
 What does this Declaration mean?
Quote:

> > I'm working with some old Pascal/Delphi code.  I have to translate
> > some stuff into C/C++.  I was wondering what the significance of this
> > type declaration was:

> > type
> >   tAddress = record end;

> > Would that be equivalent to a C/C++ void pointer or something?

> no, void pointer type is "pointer"

> > i'm not really clear on what the tAddress type represents.

> It represents nothing, and sizeof(taddress) returns 0.
> i don't see any use of this type... but I may be wrong.

> --
> Azarien

> [delete the letter v in my e-mail address]

> .

Var
start:TheAdress;a,b,c,d,e:longint;d:scar;e:pointer;c:Rttnode;stop:Tadress;
and you're know where in RAM all types starts and ends.Needed for ram
locking in drivers.

--
-
http://dmytrylavrov.narod.ru



Mon, 02 Jan 2006 18:34:38 GMT  
 What does this Declaration mean?

Quote:

> Hey,

> I'm working with some old Pascal/Delphi code.  I have to translate
> some stuff into C/C++.  I was wondering what the significance of this
> type declaration was:

> type
>   tAddress = record end;

> Would that be equivalent to a C/C++ void pointer or something?  i'm
> not really clear on what the tAddress type represents.

> Any help appreciated.

> Thanks a lot,
> Joe.

Thanks for the input guys.  I'm seeing this tAddress type being used
in records/typedefs with "unions" (i don't know what the Pascal term
is).  looks like they are used to denote the end of the actual used
space within the total space allocated for the union.

ie.

tMyType record
  firstmember : Integer;

  case Byte of
   0:(
       aa : Integer;
       ab : Integer;
       a_end : tAddress;
     );
   1:(
       ba : Integer;
       bb : Integer;
       bc : Integer;
       b_end : tAddress;
     );
   2:(
       ca : Char;
       c_end : tAddress;
     );
end;

i'm converting the tAddress variables into inline functions that
return the address that the variable would have represented.  any
comments on this approach? (aside from the fact that all references to
a_end, b_end, c_end will need () after them to be function calls in
C/C++).

ie:

typedef struct  _tagMyType
{
  Integer  firstmember;

  union{
     struct{
       Integer  aa;
       Integer  ab;
     };
     struct{
       Integer ba;
       Integer bb;
       Integer bc;
     };
     struct{
       char ca;
     );
  }
  inline void *a_end(){return &ab + sizeof(ab);)
  inline void *b_end(){return &bc + sizeof(bc);)
  inline void *c_end(){return &ca + sizeof(ca);)

Quote:
}

joe.


Tue, 03 Jan 2006 01:55:02 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Pointer declarations

2. Variant fields in object declaration in TP7 or DELPHI

3. declaration error

4. Program name declaration

5. ODBC32 API Declaration Unit for Delphi 2.0

6. {10:3 declaration}????

7. write / writeln declaration

8. Help: Unfamiliar type declaration

9. Help: Unfamiliar type declaration

10. Forward declaration Of Data

11. Dynamic array declaration

12. Constants in an Array declaration.

 

 
Powered by phpBB® Forum Software