DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005

    Convert Delphi type to C++ type

    Three problems: (Delphi type) (example)

    TAGLCoordVariantBit = (aglLatPole0,aglLonPlus,aglDegrees);
    TAGLCoordVariant = set of TAGLCoordVariantBit;

    TCoordType = Cardinal;
    PCoordSpec = ^TCoordSpec;
    TCoordSpec = record
    cType: TCoordType;
    Variant: TAGLCoordVariant;
    Coords: PCoordSpec;
    Pole, Origin: TSpherePoint;

    TAGLCircleType = (aglTwoPtCircle,aglPoleLatCircle,aglPoleDistCircle);
    TAGLCircle = packed record
    Enabled: BOOL;
    Color: TGLColor;
    Coords: PCoordSpec;
    cType: TAGLCircleType;
    Pt1: TSpherePoint;
    case TAGLCircleType of aglTwoPtCircle: (Pt2: TSpherePoint);
    aglPoleLatCircle: (Latitude: Double);
    aglPoleDistCircle: (Distance: Double);

    Pleace, how to convert in C++?

  2. #2
    Join Date
    Dec 2003
    Your going to have to explain what this stuff is in a generic language(or wait on someone who knows both). For example, is the ^variable a pointer?

    type looks like a class or struct (these are nearly identical in c++).

    This might get you started:

    struct container //create a user type with fields

    int field1; //machine word integer
    float field2; //a ieee small float
    double field3; //ieee larger float

    int * ip; //a pointer to an integer
    int array[100]; // an array of 100 integers.
    bool b; //'true' or 'false' (keywords) 0 is false, nonzero is true.


    container x; //create a variable of your type
    x.field1 = 3; // use a field.

  3. #3
    Join Date
    Nov 2003
    converting these structures to C isn't going to be that easy since pascal (it's pure pascal btw, not Delphi, which is just an IDE) has a few built-in types that don't exist in C, boolean for instace (which you can fake using int) or worse yet: sets. It's easier to convert it to C++, using std::set but that's probably too advanced for someone who hasn't used C++ and the STL before. My advice: don't try to create the spitting image of these data structures in C. Instead, go the drawing board and see what your C app really needs. You may find out that some pascal features are an artifact of pascal itself (i.e., its weak at pointers, so it uses different constructs, it's strong at enum types so there are plenty of them and so on).
    Danny Kalev

Similar Threads

  1. Replies: 5
    Last Post: 10-12-2005, 02:08 PM
  2. how to convert wchar_t* type to int
    By swapnil_paranja in forum C++
    Replies: 3
    Last Post: 06-30-2005, 06:55 AM
  3. Replies: 1
    Last Post: 06-10-2002, 11:10 AM
  4. Help a mere Delphi convert! with ASP.NET
    By Bob Russell in forum .NET
    Replies: 3
    Last Post: 05-29-2002, 12:07 PM
  5. What is the UDT?
    By Tahui in forum VB Classic
    Replies: 2
    Last Post: 11-22-2000, 10:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.