IdentifiantMot de passe
Loading...
Mot de passe oubli� ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les r�ponses en temps r�el, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++Builder Discussion :

Probl�me dans un code delphi dans C++Builder


Sujet :

C++Builder

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Membre �clair�
    Homme Profil pro
    Consultant technique
    Inscrit en
    Juillet 2002
    Messages
    519
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activit� : Consultant technique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 519
    Par d�faut Probl�me dans un code delphi dans C++Builder
    Bonjour,
    j'essai de compiler du code delphi dans C++Builder dans l'espoir de pouvoir utiliser les composants asphyre 4.0.9 dans une application C++Builder.
    J'ai pu adapter le code jusqu'� un certain point. En effet, j'ai maintenant une erreur que je ne comprend pas (je ne connais pas bien le pascal).
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    type
     PPoint2px = ^TPoint2px;
     TPoint2px = record
      x, y: Integer;
     
      class operator Add(const a, b: TPoint2px): TPoint2px; //ligne 49
      class operator Subtract(const a, b: TPoint2px): TPoint2px;
      class operator Multiply(const a, b: TPoint2px): TPoint2px;
      class operator Divide(const a, b: TPoint2px): TPoint2px;
     
      class operator Negative(const v: TPoint2px): TPoint2px;
      class operator Multiply(const v: TPoint2px; const k: Real): TPoint2px;
      class operator Multiply(const v: TPoint2px; const k: Integer): TPoint2px;
      class operator Divide(const v: TPoint2px; const k: Real): TPoint2px;
      class operator Divide(const v: TPoint2px; const k: Integer): TPoint2px;
      class operator Implicit(const Point: TPoint): TPoint2px;
      class operator Implicit(const Point: TPoint2px): TPoint;
      class operator Equal(const a, b: TPoint2px): Boolean;
      class operator NotEqual(const a, b: TPoint2px): Boolean;
      end;
    J'ai l'erreur suivante :
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    [Pascal Erreur] Vectors2px.pas(49): 'END' attendu(e) mais 'CLASS' trouvé(e)
    Quelqu'un � une id�e?

  2. #2
    Membre �prouv�
    Avatar de Sunchaser
    Homme Profil pro
    OPNI (Objet Programmant Non Identifi�)
    Inscrit en
    D�cembre 2004
    Messages
    2 059
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 54
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activit� : OPNI (Objet Programmant Non Identifi�)
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : D�cembre 2004
    Messages : 2 059
    Par d�faut
    Bonsoir,

    Je risque de me planter un peu , mais je tente une r�ponse ...

    Le 'record' en Delphi n'est pas un �quiv de 'Struct' ?
    Alors il faudrait �crire :
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
     
    typedef struct
    {
         int x;
         int y;
    }TPoint2px;
    typedef TPoint2px *PPoint2px;
    Et ainsi, virer le 'End' apres toutes les d�clarations des 'class', qui semblerait alors mal plac� ...
    ?

    En esp�rant t'aider,
    @ +

  3. #3
    Membre �clair�
    Homme Profil pro
    Consultant technique
    Inscrit en
    Juillet 2002
    Messages
    519
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activit� : Consultant technique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 519
    Par d�faut
    C'est du delphi?
    Parce que le fichier doit rester en delphi pour �tre toujours compatible delphi et se compil� aussi dans C++Builder.

    Le probl�me viendrait plut�t qu'il n'aime pas les class dans ce machin (je n'ai toujours pas compris si c'est un type ou un record).
    Faut-il que je mette la totalit� du fichier ici pour aider � trouver la solution?

  4. #4
    Membre �prouv�
    Avatar de Sunchaser
    Homme Profil pro
    OPNI (Objet Programmant Non Identifi�)
    Inscrit en
    D�cembre 2004
    Messages
    2 059
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 54
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activit� : OPNI (Objet Programmant Non Identifi�)
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : D�cembre 2004
    Messages : 2 059
    Par d�faut
    Citation Envoy� par gandf
    C'est du delphi?
    ...
    Faut-il que je mette la totalit� du fichier ici pour aider � trouver la solution?
    Ah que non, d�sol�, c'est pas du Delphi dans ce que j'ai dis ...mille et une plates excuses, j'avais compris (de travers) qu'il fallait tenter une traduction.

    Ben pourquoi pas mettre tout le fichier, sait on jamais.
    Je rejetterais un oeil ce soir, bien que je ne pr�tende pas avoir forcement la solution.

    @ +

  5. #5
    Membre chevronn�

    Profil pro
    Inscrit en
    Juin 2005
    Messages
    351
    D�tails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juin 2005
    Messages : 351
    Par d�faut
    Citation Envoy� par gandf
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    type
     PPoint2px = ^TPoint2px;
     TPoint2px = record
      x, y: Integer;
      end;
    
      class ...
    Je ne suis pas un expert en delphi, mais si tu d�clares un record, j'ai pas l'impression que tu puisses mettre des classes dedans... Tu dois d'abord fermer ton record (le END r�clam� par l'erreur), puis d�clarer tes class.
    D'apr�s ce que j'ai vu dans un fichier ".pas", le type ne se ferme pas, il se termine lorsqu'il rencontre un "implementation"...

    Avis sans garantie.

    PS: Pourquoi ne pas poser la question au groupe Delphi ?

  6. #6
    Membre �clair�
    Homme Profil pro
    Consultant technique
    Inscrit en
    Juillet 2002
    Messages
    519
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activit� : Consultant technique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 519
    Par d�faut
    En fait, ce code compile bien sous delphi mais pas dans C++Builder. Ce doit-�tre quelques chose que C++Builder ne prend pas en compte. C'est pour �a que je pose la question ici.

    J'ai mis l'int�gralit� du fichier.

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    unit Vectors2px;
    interface
     
    //---------------------------------------------------------------------------
    uses
     Types, Math;
     
    //---------------------------------------------------------------------------
    type
     PPoint2px = ^TPoint2px;
     TPoint2px = record
      x, y: Integer;
     
      class operator Add(const a, b: TPoint2px): TPoint2px;
      class operator Subtract(const a, b: TPoint2px): TPoint2px;
      class operator Multiply(const a, b: TPoint2px): TPoint2px;
      class operator Divide(const a, b: TPoint2px): TPoint2px;
     
      class operator Negative(const v: TPoint2px): TPoint2px;
      class operator Multiply(const v: TPoint2px; const k: Real): TPoint2px;
      class operator Multiply(const v: TPoint2px; const k: Integer): TPoint2px;
      class operator Divide(const v: TPoint2px; const k: Real): TPoint2px;
      class operator Divide(const v: TPoint2px; const k: Integer): TPoint2px;
      class operator Implicit(const Point: TPoint): TPoint2px;
      class operator Implicit(const Point: TPoint2px): TPoint;
      class operator Equal(const a, b: TPoint2px): Boolean;
      class operator NotEqual(const a, b: TPoint2px): Boolean;
      end;
    //---------------------------------------------------------------------------
     TPoints2px = class
     private
      Data: array of TPoint2px;
      DataCount: Integer;
     
      function GetItem(Num: Integer): PPoint2px;
      procedure Request(Amount: Integer);
      function GetMemAddr(): Pointer;
     public
      property MemAddr: Pointer read GetMemAddr;
      property Count: Integer read DataCount;
      property Item[Num: Integer]: PPoint2px read GetItem; default;
     
      function Add(const Point: TPoint2px): Integer; overload;
      function Add(x, y: Integer): Integer; overload;
      procedure Remove(Index: Integer);
      procedure RemoveAll();
     
      procedure CopyFrom(Source: TPoints2px);
      procedure AddFrom(Source: TPoints2px);
     
      constructor Create();
      destructor Destroy(); override;
     end;
     
    //---------------------------------------------------------------------------
    const
     ZeroPoint2px : TPoint2px = (x: 0; y: 0);
     UnityPoint2px: TPoint2px = (x: 1; y: 1);
     InfPoint2px  : TPoint2px = (x: Low(Integer); y: Low(Integer));
     
    //---------------------------------------------------------------------------
    function Point2px(x, y: Integer): TPoint2px;
    function Length2px(const v: TPoint2px): Real;
    function Angle2px(const v: TPoint2px): Real;
    function Lerp2px(const v0, v1: TPoint2px; Alpha: Real): TPoint2px;
    function Dot2px(const a, b: TPoint2px): Integer;
     
    //---------------------------------------------------------------------------
    implementation
     
    //---------------------------------------------------------------------------
    const
     CacheSize = 128;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Add(const a, b: TPoint2px): TPoint2px;
    begin
     Result.x:= a.x + b.x;
     Result.y:= a.y + b.y;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Subtract(const a, b: TPoint2px): TPoint2px;
    begin
     Result.x:= a.x - b.x;
     Result.y:= a.y - b.y;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Multiply(const a, b: TPoint2px): TPoint2px;
    begin
     Result.x:= a.x * b.x;
     Result.y:= a.y * b.y;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Divide(const a, b: TPoint2px): TPoint2px;
    begin
     Result.x:= a.x div b.x;
     Result.y:= a.y div b.y;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Negative(const v: TPoint2px): TPoint2px;
    begin
     Result.x:= -v.x;
     Result.y:= -v.y;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Multiply(const v: TPoint2px;
     const k: Integer): TPoint2px;
    begin
     Result.x:= v.x * k;
     Result.y:= v.y * k;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Multiply(const v: TPoint2px;
     const k: Real): TPoint2px;
    begin
     Result.x:= Round(v.x * k);
     Result.y:= Round(v.y * k);
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Divide(const v: TPoint2px;
     const k: Integer): TPoint2px;
    begin
     Result.x:= v.x div k;
     Result.y:= v.y div k;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Divide(const v: TPoint2px;
     const k: Real): TPoint2px;
    begin
     Result.x:= Round(v.x / k);
     Result.y:= Round(v.y / k);
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Implicit(const Point: TPoint): TPoint2px;
    begin
     Result.x:= Point.X;
     Result.y:= Point.Y;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Implicit(const Point: TPoint2px): TPoint;
    begin
     Result.X:= Point.x;
     Result.Y:= Point.y;
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.Equal(const a, b: TPoint2px): Boolean;
    begin
     Result:= (a.x = b.x)and(a.y = b.y);
    end;
     
    //---------------------------------------------------------------------------
    class operator TPoint2px.NotEqual(const a, b: TPoint2px): Boolean;
    begin
     Result:= (a.x <> b.x)or(a.y <> b.y);
    end;
     
    //---------------------------------------------------------------------------
    function Point2px(x, y: Integer): TPoint2px;
    begin
     Result.x:= x;
     Result.y:= y;
    end;
     
    //---------------------------------------------------------------------------
    function Length2px(const v: TPoint2px): Real;
    begin
     Result:= Hypot(v.x, v.y);
    end;
     
    //---------------------------------------------------------------------------
    function Angle2px(const v: TPoint2px): Real;
    begin
     Result:= ArcTan2(v.y, v.x);
    end;
     
    //---------------------------------------------------------------------------
    function Lerp2px(const v0, v1: TPoint2px; Alpha: Real): TPoint2px;
    begin
     Result.x:= Round(v0.x + (v1.x - v0.x) * Alpha);
     Result.y:= Round(v0.y + (v1.y - v0.y) * Alpha);
    end;
     
    //---------------------------------------------------------------------------
    function Dot2px(const a, b: TPoint2px): Integer;
    begin
     Result:= (a.x * b.x) + (a.y * b.y);
    end;
     
    //---------------------------------------------------------------------------
    constructor TPoints2px.Create();
    begin
     inherited;
     
     DataCount:= 0;
    end;
     
    //---------------------------------------------------------------------------
    destructor TPoints2px.Destroy();
    begin
     DataCount:= 0;
     SetLength(Data, 0);
     
     inherited;
    end;
     
    //---------------------------------------------------------------------------
    function TPoints2px.GetMemAddr(): Pointer;
    begin
     Result:= @Data[0];
    end;
     
    //---------------------------------------------------------------------------
    function TPoints2px.GetItem(Num: Integer): PPoint2px;
    begin
     if (Num >= 0)and(Num < DataCount) then Result:= @Data[Num]
      else Result:= nil;
    end;
     
    //---------------------------------------------------------------------------
    procedure TPoints2px.Request(Amount: Integer);
    var
     Required: Integer;
    begin
     Required:= Ceil(Amount / CacheSize) * CacheSize;
     if (Length(Data) < Required) then SetLength(Data, Required);
    end;
     
    //---------------------------------------------------------------------------
    function TPoints2px.Add(const Point: TPoint2px): Integer;
    var
     Index: Integer;
    begin
     Index:= DataCount;
     Request(DataCount + 1);
     
     Data[Index]:= Point;
     Inc(DataCount);
     
     Result:= Index;
    end;
     
    //---------------------------------------------------------------------------
    function TPoints2px.Add(x, y: Integer): Integer;
    begin
     Result:= Add(Point2px(x, y));
    end;
     
    //---------------------------------------------------------------------------
    procedure TPoints2px.Remove(Index: Integer);
    var
     i: Integer;
    begin
     if (Index < 0)or(Index >= DataCount) then Exit;
     
     for i:= Index to DataCount - 2 do
      Data[i]:= Data[i + 1];
     
     Dec(DataCount);
    end;
     
    //---------------------------------------------------------------------------
    procedure TPoints2px.RemoveAll();
    begin
     DataCount:= 0;
    end;
     
    //---------------------------------------------------------------------------
    procedure TPoints2px.CopyFrom(Source: TPoints2px);
    var
     i: Integer;
    begin
     Request(Source.DataCount);
     
     for i:= 0 to Source.DataCount - 1 do
      Data[i]:= Source.Data[i];
     
     DataCount:= Source.DataCount;
    end;
     
    //---------------------------------------------------------------------------
    procedure TPoints2px.AddFrom(Source: TPoints2px);
    var
     i: Integer;
    begin
     Request(DataCount + Source.DataCount);
     
     for i:= 0 to Source.DataCount - 1 do
      Data[i + DataCount]:= Source.Data[i];
     
     Inc(DataCount, Source.DataCount);
    end;
     
    //---------------------------------------------------------------------------
    end.

  7. #7
    Membre �prouv�
    Profil pro
    Inscrit en
    Ao�t 2006
    Messages
    190
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Ao�t 2006
    Messages : 190
    Par d�faut
    Bonsoir,
    Cela m'�tonne que le code que tu proposes compile sous delphi, et pas sur builder. En effet, dans les deux cas, le m�me compilateur est utilis�... c'est � dire dcc32.exe...
    Cordialement,
    Benjamin

  8. #8
    Membre �clair�
    Homme Profil pro
    Consultant technique
    Inscrit en
    Juillet 2002
    Messages
    519
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activit� : Consultant technique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 519
    Par d�faut
    il y a certaines choses qui sont possible sous delphi et pas sous C++Builder comme par exemple les propri�t�s de type tableau qui doivent �tre modifi�e pour �tre compiler sous C++Builder.
    Il y a dans l'aide (j'ai la version 6 et BDS2006 de c++Builder) de la version 6 une section qui s'intitule "Types sans correspondants" qui donne un exemple de complication.
    Dans BDS2006, le code compile parfaitement en delphi mais plante si je coche la case pour g�n�rer les fichiers permettant d'avoir les composants dans la personnalit� C++.

  9. #9
    Membre �clair�
    Homme Profil pro
    Consultant technique
    Inscrit en
    Juillet 2002
    Messages
    519
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activit� : Consultant technique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Juillet 2002
    Messages : 519
    Par d�faut
    Personne n'a d'id�e?
    Il vaut mieux que je demande sur le forum delphi?

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. R�ponses: 11
    Dernier message: 01/08/2008, 11h40
  2. [D7] Faire un doEvents pour Word dans le code Delphi.
    Par dacid dans le forum D�buter
    R�ponses: 0
    Dernier message: 15/02/2008, 10h26
  3. Probl�me dans un code delphi dans C++Builder
    Par gandf dans le forum Delphi
    R�ponses: 5
    Dernier message: 27/03/2007, 23h14
  4. [Upload] Probl�me pour uploader un fichier dans mon code
    Par Peuplarchiste dans le forum Langage
    R�ponses: 2
    Dernier message: 27/05/2006, 09h48
  5. [XSL/JavaScript]probl�me d'int�gration code JS dans le XSL
    Par Devil666 dans le forum G�n�ral JavaScript
    R�ponses: 4
    Dernier message: 27/04/2005, 16h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo