AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

C++ nach Delphi

Ein Thema von keksman · begonnen am 12. Aug 2007 · letzter Beitrag vom 12. Aug 2007
Antwort Antwort
keksman
(Gast)

n/a Beiträge
 
#1

C++ nach Delphi

  Alt 12. Aug 2007, 01:44
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

Gruß
keksman
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#2

Re: C++ nach Delphi

  Alt 12. Aug 2007, 01:46
uint8 = unsigned int 8 bit = byte
uint16 = unsigned int 16 bit = word
uint32 = unsigned int 32 bit = longword
  Mit Zitat antworten Zitat
keksman
(Gast)

n/a Beiträge
 
#3

Re: C++ nach Delphi

  Alt 12. Aug 2007, 01:51
Ich danke dir
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?
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#4

Re: C++ nach Delphi

  Alt 12. Aug 2007, 01:59
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.
  Mit Zitat antworten Zitat
keksman
(Gast)

n/a Beiträge
 
#5

Re: C++ nach Delphi

  Alt 12. Aug 2007, 02:07
Jap danke so klappt es! (mit den array of char war natürlich richtig )
  Mit Zitat antworten Zitat
Christian Seehase
(Co-Admin)

Registriert seit: 29. Mai 2002
Ort: Hamburg
11.105 Beiträge
 
Delphi 11 Alexandria
 
#6

Re: C++ nach Delphi

  Alt 12. Aug 2007, 02:35
Moin keksman,

Du sollest auch noch darauf achten, welches Alignment vor der Struktur eingestellt ist, ansonsten könnte die Struktur falsch gefüllt werden.
Tschüss Chris
Die drei Feinde des Programmierers: Sonne, Frischluft und dieses unerträgliche Gebrüll der Vögel.
Der Klügere gibt solange nach bis er der Dumme ist
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:32 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