I would assume that Gord is using the EDCDSECT program which is legally part of 
the XLC compiler. It assembles the DSECT -- can be either by itself or part of 
some larger assembly -- and massages SYSADATA to produce a C-legal struct.

The result -- particularly for older IBM DSECTs -- is often spectacularly 
awfully unreadable, but nonetheless is syntactically and "layout-wise" correct. 
For simple DSECTs it does a very adequate job. I have used it on perhaps 100 
DSECTs and in that time have perhaps seen twice where the layout was truly 
wrong. Its worst flaw IMHO is to make FOO DS FL8 and similar into char foo[8] 
which is right layout-wise but wrong logically. At least you get a compile-time 
error if you say foo = 3; and can respond by editing the struct. The moral of 
the story is that if it is your own DSECT you probably want to try to get it 
right the first time so you don't have to keep re-editing the EDCDSECT output. 

Comments are preserved, kinda sorta.

Our local hero Peter Relson developed an internal tool that does a much better 
job, and z/OS is now shipping C struct header files for many, many MVS control 
blocks. (The tool is not suitable for release because it uses PL/X input, which 
is much better because it is closer to C than HLASM is. PL/X is more strongly 
typed than HLASM.)

Agree with Lionel's recommendation. Even if the usage is going to be 90% C and 
10% HLASM you want to do the DSECT first and work from there.

This has been discussed here previously, including someone who posted regex 
that will automate the conversion of char foo[8] to long long foo;

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Paul Gilmartin
Sent: Friday, February 14, 2020 10:26 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Convert a Metal C control block mapping to Assembler DSECT ?

On Fri, 14 Feb 2020 10:31:02 -0500, Gord Tomlin wrote:

>On 2020-02-14 10:17, Lionel B Dyck wrote:
>> Is this possible, and more importantly, has anyone done it and be willing to
>> share?
>
>If the control block is one of your own creation, I'd recommend that you
>make the DSECT the original form, and then create the header file from
>the DSECT. It's much easier!
> 
Have you any tips and techniques.  For example, I suspect ORG becomes
struct and/or union.  How can one generate the terminating "}" in the
right place?

Is asmadata of assistance for this?  MACROs to assist?  Should the
original be preserved as embedded comments?

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to