Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi C++ nach Delphi (https://www.delphipraxis.net/97521-c-nach-delphi.html)

keksman 12. Aug 2007 00:44


C++ nach Delphi
 
Hallo,

ich möchte folgenden record gerne in Delphi konvertieren:
Code:
typedef struct
{
    uint8   cmd;
    uint8   error;
    uint16  size;
    uint8   gamename[4];
    uint8   version1;
    uint8   version2;
    uint8   version3;
    uint16  build;
    uint8   platform[4];
    uint8   os[4];
    uint8   country[4];
    uint32  timezone_bias;
    uint32  ip;
    uint8   I_len;
    uint8   I[1];
}
Was ich jetzt nicht verstehe ist, was es mit dem uint8 usw. aus sich hat. Delphi erkennt bei mir nur uint aber kein uint8.
Hoffe mir kann da jemand weiterhelfen :wink:

Gruß
keksman

Muetze1 12. Aug 2007 00:46

Re: C++ nach Delphi
 
uint8 = unsigned int 8 bit = byte
uint16 = unsigned int 16 bit = word
uint32 = unsigned int 32 bit = longword

keksman 12. Aug 2007 00:51

Re: C++ nach Delphi
 
Ich danke dir :thumb:
Delphi-Quellcode:
type
  uint8 = byte;
  uint16 = word;
  uint32 = longword;
  TAuth= record
    cmd:       uint8;
    error:     uint8;
    size:      uint16;
    gamename:  uint8;
    version1:  uint8;
    version2:  uint8;
    version3:  uint8;
    Build:     uint16;
    platform:  uint8;
    os:        uint8;
    Country:   uint8;
    timezone:  uint32;
    ip:        uint32;
    I_len:     uint8;
    I:         uint8;
  end;
Sollte so stimmen oder?

Muetze1 12. Aug 2007 00:59

Re: C++ nach Delphi
 
Nein, du hast die Arrays übersehen.

Delphi-Quellcode:
type
  uint8 = byte;
  uint16 = word;
  uint32 = longword;
  TAuth= packed record
    cmd:       uint8;
    error:     uint8;
    size:      uint16;
    gamename:  array[0..3] of uint8;
    version1:  uint8;
    version2:  uint8;
    version3:  uint8;
    Build:     uint16;
    platform:  array[0..3] of uint8;
    os:        array[0..3] of uint8;
    Country:   array[0..3] of uint8;
    timezone:  uint32;
    ip:        uint32;
    I_len:     uint8;
    I:         array[0..1] of uint8;
  end;
Bei den meisten Arrays liegt aber die Vermutung nahe, dass es sich um Zeichen Arrays handelt also wahrscheinlich nicht array[] of uint8 sondern array[] of char.

keksman 12. Aug 2007 01:07

Re: C++ nach Delphi
 
Jap danke so klappt es! (mit den array of char war natürlich richtig :oops: )

Christian Seehase 12. Aug 2007 01:35

Re: C++ nach Delphi
 
Moin keksman,

Du sollest auch noch darauf achten, welches Alignment vor der Struktur eingestellt ist, ansonsten könnte die Struktur falsch gefüllt werden.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:10 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz