Why doesn’t this valid C program compile?

I wanted to use some C code I found, and when I tried to compile the source, it kept complaining because of a syntax error.

... 
void printMD()
{
printf("ABC ");
int i;
i = 0;
printf("I is %i\n",i);
}
...

The original code was several thousand lines long. The (first) error message was

ERROR CCN3275 ./perfutic.c:4     Unexpected text 'int' encountered.                                        

There were two challanges

  1. Create the smallest program to isolate
  2. Find out why the code failed to comile

Isolate the problem

I put #ifdef temp…. #endif around blocks of code to remove irrelevant code. This worked, but I quickly got into a mess where I had many #ifdef…#endif and matching them up.

I saved a copy of the program, then used #ifdef..#endif to ignore blocks of code. If this made no change to the compile, then delete the block, and add more #ifdef…#endif. If it caused other error messages, remove the #ifdef..#endif statements, and try a smaller block of code.

Eventually I got down to the code above.

Why did the code fail to compile

I spent half a day scratching my head, and when I came back next morning, I had a flash of inspiration.

Later versions of C are more flexible in some areas.

In early days of the C compiler you had to define all variables before you did any work. With later versions of the C compiler this restriction was relaxed, so you could fall a function, the define a variable.

See intermingled declarations and code: variable declaration is no longer restricted to file scope or the start of a compound statement (block) in the ISO C99 specification

The makefile I was using was

cparms ="-Wc,SO,LIST(lst31),XREF,ILP32,DLL,SSCOM,SHOWINC,DEFINE(MVS=1)"  
cc -c -o $@ -I"//'MQCD94.SCSQC370'" -I'/usr/include' -I. $(cparms) $<

You control the level of C using the LANGLVL option.

The cc command produced( in the listing)

Language level. . . . . . . . : *COMMONC:NOTEXTAFTERENDIF 

With the c99 command, the code compiled, and the listing had

 Language level. . . . . . . . : *STDC99:NOTEXTAFTERENDIF 

With the original compile, I was using the options which did not allow variables to be defined after executable code.

Instead of using cc, I could have used cc with langlvl(EXTENDED).

Why doesn’t this valid C program compile?

The short answer is : I was using the wrong compiler options.

Whoosh goes my z/OS console

I was having problems IPLing z/OS. Once you can logon to TSO you can use SDSF to display the console. The problem is when the system fails before you can logon to TSO.

When z/OS is IPLed a few messages are displayed, then the console goes into wrap mode, and message roll past faster than I can read them.

You can change the roll mode using the command to not delete messages automatically

K S,DEL=N

You can then use

K

to clear the screen.

You can use K S,REF to display and overtype values. For example RTME=5 says roll every 5 seconds, RTME=1/4 says roll every quarter of a second.

How much free space do my ZFS have?

I was running into a problem where my file systems were running out of space. I knew I had some spare space – but where was it?

The command

zfsadm aggrinfo

produced output like

COLIN.ZFS.ZOWE.CONFIG (R/W COMP): 1943183 K free out of total 2975040      
COLIN.ZFS.ZOWE33.CONFIG (R/W COMP): 7327 K free out of total 421920
COLIN.OPENSSL.ZFS2 (R/W COMP): 2407159 K free out of total 7200000
ZFS.S0W1.SYSTEM (R/W COMP): 1263 K free out of total 1440
ZFS.Z31B.CNJ (R/O COMP): 80605 K free out of total 648000
ZFS.S0W1.WEB (R/W COMP): 9839 K free out of total 10080

You can sort it to give the largest space at the bottom.

  • -n means treat the value as a number
  • -k 4,4 means sort by the 4th field.
zfsadm aggrinfo |sort -n -k4,4

Gave

ZFS.Z31B.VERSION (R/W COMP): 33 K free out of total 3823200
ZFS.Z31B.ZEDC (R/O COMP): 367 K free out of total 1440
...
COLIN.OPENSSL.ZFS2 (R/W COMP): 2407159 K free out of total 7200000
COLIN.ZOPEN.ZFS (R/W COMP): 2446835 K free out of total 6144480