Home > Back-end >  What is the meaning of char foo(|10|) in C?
What is the meaning of char foo(|10|) in C?

Time:12-16

I'm a very experienced C programmer, but recently I came across some code on a mainframe that has a local variable. This is in a simple C function that declares this variable, and then strcpy / strcats two string sinto it, and then tries an fopen.

char foo(|10|);

This code is very old. Possibly even K&R C old. I'm wondering if this is some obscure compiler extension or an adaptation to a keyboard that doesn't have [] or something like that.

Anyone know if this declaration is 'special'?

This is a standard Z/OS mainframe. I'm not sure what compiler is used.

CodePudding user response:

It seems to be an early or non-standard form of digraph. The code was probably written using EBCDIC instead of ASCII, and EBCDIC doesn't have [ ] characters (at least not in all code pages).

I found the manual for SAS/C, a C compiler apparently meant for System/370. On page 2-10 (page 42 of the pdf) you can see they list (| |) as "alternate forms" for [ ].

(Though apparently | is not in all the code pages either; but maybe it was in a code page that was more commonly used? I don't know.)

C99 also included digraphs (and trigraphs) to solve the same problem, but they used <: :> as the digraphs, and ??( ??) for the trigraphs.

  • Related