Well, it's one of those things. EDCDSECT does not do a perfect job but it does 
a better job than no job at all. You're not using it "in production" so if it 
does a 95% job you are 95% ahead. Well, in my experience it is about 95% pretty 
much right and about 1% totally wrong, where it gets an offset wrong. Sometimes 
it generates such a flipping mess of unions that it is hopeless to read. It 
tends to get unions wrong. How do I say this? Something that logically should 
have been rendered

union x {int a; int b;};
union y {int c; int d;};

it instead renders as

union z {int a; int c;};
union w {int b; int d;};

Yes, of course, assembler is weakly typed, and even there, people misuse what 
typing there is. EDCDSECT has some options, for example, how do you want to 
deal with

FLAG  DS  X
INPUT EQU X'80'
OPEN  EQU X'40'
etc.

Do you want INPUT to be a one-bit integer or a #define mask suitable for use 
with logical or? EDCDSECT gives you a choice.

You have a choice whether to lowercase the assembler symbols (because old 
assembler is typically all uppercase and C culture is lowercase).

Yes, there would be some challenges going the other direction: Foo and foo are 
different C symbols but the same assembler symbol (but do you use both in the 
same struct???). C struct symbols typically have local scope; all assembler 
symbols have global scope. You could deal with the latter by letting the user 
specify a prefix or by rendering

struct Foo { int Bar; };

in assembler as

Foo_Bar DS F

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Paul Gilmartin
Sent: Saturday, March 19, 2016 2:26 PM
To: [email protected]
Subject: Re: C struct to DSECT utility?

On Sat, 19 Mar 2016 12:22:44 -0700, Charles Mills wrote:

>Off the wall question: IBM ships EDCDSECT, which will convert an 
>assembler DSECT (actually, the ADATA from assembling a DSECT) to a C struct.
> 
I had heard of such utilities from ISVs; I had been unaware of this from IBM.
Like Samuel Johnson's politically-incorrect dog, it surprises me that this is 
done at all.  Some challenges:

o Indiscriminate use of ORG, not always readily rendered as "union".

o Weakness of assembler typing.  For example, should:
      A   DC   A(SYMBOL)
  be rendered as which of:
      char *A = &SYMBOL;  /* or: */
      long A = SYMBOL;
One can take a guess according to whether SYMBOL is relocatable or absolute and 
be right some of the time.

>Is there anything, or combination of things, that will go the other 
>direction? Convert a C struct into a DSECT?
>
Backward?  Likewise challenges:

o Similar member names in different structs.  Qualify them?

o References to typedefs and structure tags from earlier headers.

o Judicious reliance on case-sensitivity.  Ok; I'll grant that I'm a partisan\
  and I'd not be surprised to encounter nor loath to use in a C program
  such as:
      char *Auml = "Ä"
      char *auml = "ä"
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
[email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to