- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: using sizeof
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
09-13-2005 03:15 AM
09-13-2005 03:15 AM
sizeof(variable name) and the correct size will return.
long x[10][10];
char y[20];
struct XXX
{
long x[10][10];
char y[20];
}strct;
sizeof(x) is 100;
sizeof(y) is 20;
sizeof(strct) is 120;
I have done some testing on the itanium and found it works! Is this just a fluke or is this a valid way to do this on the OpenVMS platform?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2005 03:25 AM
09-13-2005 03:25 AM
SolutionThis works. I think that this is part of the ANSIC standard.
The documentation:
http://h71000.www7.hp.com/commercial/c/docs/6180profile_016.html#index_x_563
says that the parameter to sizeof can be an expression.
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2005 06:09 AM
09-13-2005 06:09 AM
Re: using sizeof
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2005 06:17 AM
09-13-2005 06:17 AM
Re: using sizeof
Thanks much!
Dave,
Thanks, I calculated wrong. It's 400
and 420 for 'strct.'
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2005 10:44 AM
09-13-2005 10:44 AM
Re: using sizeof
One thing to beware of... the sizes of objects might differ between your Windows and OpenVMS code. The OpenVMS compiler, by default, will align fields within a structure on their natural boundaries, inserting "padding" where necessary. This may result in a structure larger than the simple sum of the component fields. Usually this isn't a problem, but if you're expecting to share binary data files across platforms, you might need to check that the structures are compatible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 02:59 AM
09-14-2005 02:59 AM
Re: using sizeof
Thanks! When we share data across platforms in the Client/Server environment we are using the #pragma pack(1) on our Windows clients and
#pragma nomember_alignment on the HP OpenVMS server aligning both structure members on byte boundries.
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2005 03:07 AM
09-14-2005 03:07 AM
Re: using sizeof
Better use a portable data format like XDR or XML.