- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Convert pascal to C
Operating System - OpenVMS
1820635
Members
1881
Online
109626
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 10:29 AM
тАО11-06-2006 10:29 AM
Convert pascal to C
I need to convert some legacy pascal program to C on my Alpha, somehow I didn't get this right. What is wrong with my C code? Any ideas?
Thanks in advance.
-Ivan
=======================================
(* convert this pascal code to C *)
_UQUAD = [QUAD,UNSAFE] PACKED RECORD
L0,
L1 : UNSIGNED;
END;
Tel = [aligned] PACKED RECORD
X0 : [BIT(3)] 0..7;
X1 : _UQUAD;
X2 : BOOLEAN;
X3 : ARRAY [1..16] OF _UQUAD;
X4 : ARRAY [1..16] OF BOOLEAN;
END;
======================================
// This is my C code
struct tel {
unsigned X0 : 3;
uint64 X1;
uint64 X2;
bool X3;
uint64 X4[16];
bool X5[16];
};
Thanks in advance.
-Ivan
=======================================
(* convert this pascal code to C *)
_UQUAD = [QUAD,UNSAFE] PACKED RECORD
L0,
L1 : UNSIGNED;
END;
Tel = [aligned] PACKED RECORD
X0 : [BIT(3)] 0..7;
X1 : _UQUAD;
X2 : BOOLEAN;
X3 : ARRAY [1..16] OF _UQUAD;
X4 : ARRAY [1..16] OF BOOLEAN;
END;
======================================
// This is my C code
struct tel {
unsigned X0 : 3;
uint64 X1;
uint64 X2;
bool X3;
uint64 X4[16];
bool X5[16];
};
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 11:31 AM
тАО11-06-2006 11:31 AM
Re: Convert pascal to C
Well, I don't pretend to remember the PASCAL allignment rules vs C rules, but what you show has simple miscounts/mislabels.
Should the C not be:
struct tel {
unsigned X0 : 3;
uint64 X1;
bool X2;
uint64 X3[16];
bool X4[16];
};
Now what does that 'bool' map to through your includes? Is every bool becoming an int thus taking 64 bytes? The array of boolean in Pascal is probably a bit-array taking 2 bytes.
Be sure to write a trivial test program allocating this structure in both languages and compile with full listing showing the variable allocations.
Is the structure just use in runtime by a single language, or exchanged between languages, or stored on disk where you need to use an old file? For the first case you can just pick your favourite C constructs. For the other you'll need to control aligment down to the bit.
Hope this helps a little,
Hein.
Should the C not be:
struct tel {
unsigned X0 : 3;
uint64 X1;
bool X2;
uint64 X3[16];
bool X4[16];
};
Now what does that 'bool' map to through your includes? Is every bool becoming an int thus taking 64 bytes? The array of boolean in Pascal is probably a bit-array taking 2 bytes.
Be sure to write a trivial test program allocating this structure in both languages and compile with full listing showing the variable allocations.
Is the structure just use in runtime by a single language, or exchanged between languages, or stored on disk where you need to use an old file? For the first case you can just pick your favourite C constructs. For the other you'll need to control aligment down to the bit.
Hope this helps a little,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2006 12:11 AM
тАО11-07-2006 12:11 AM
Re: Convert pascal to C
What is the problem you're hitting?
From the Pascal I got a size of 202 bytes (layout attached). The array of BOOLEAN is 64 bytes so its going to be confusing to map. At a guess I would go:
X0 char
X1 uint64
X2 byte
X3 uint64[16]
X4 uint[16]
No idea where you've got the additional field from (unless I've missed something obvious).
From the Pascal I got a size of 202 bytes (layout attached). The array of BOOLEAN is 64 bytes so its going to be confusing to map. At a guess I would go:
X0 char
X1 uint64
X2 byte
X3 uint64[16]
X4 uint[16]
No idea where you've got the additional field from (unless I've missed something obvious).
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP