Article View: comp.std.c
Article #4170Re: Maximum length of line of C code
From: Colin Plumb
Date: Wed, 04 Oct 1995 05:54
Date: Wed, 04 Oct 1995 05:54
70 lines
1898 bytes
1898 bytes
In article <44qg8v$s1m@ixnews2.ix.netcom.com>,
Richard Berthold <berthold@ix.netcom.com> wrote:
> Is there a limit to the number of characters in a physical line of C
> code which a "standard" compiler must be able to read (ie all lines
> must be less than 80 characters etc)?
> If there is no standard limit, does anyone know of any current
> compilers with small limits ie < 512 ?
The standard only guarantees 509 characters will be acceptable for *logical*
lines, *after* backslash-continuedd lines have been spliced together.
I don't think your technique is going to work in general.
What you can do is insert *unescaped* newlines anywhere a space is legal.
The they're separate logical lines (a single expression can span multiple
lines) and the problem doesn't arise.
> Must all compilers support \ as a line continuation character?
By the standard, yes.
> Is it always a continuation even if preceded by another \?
No. If preceded by an *odd* number of backslashes, it's the second
part of a \\ escape, which corresponds to \ in the middle of a line.
(It better be inside a string literal or it's not valid C.)
For example, I cannot split:
printf("Hello, world!\n");
into:
printf("Hello, world!\\
n");
The latter is roughly equivalent to
printf("Hello, world!\\\nn");
I can, however, split it into:
p\
r\
i\
n\
t\
f
(
"\
H\
e\
l\
l\
o\
,\
\
w\
o\
r\
l\
d\
!\
\n\
"
)
;
Note the places I did *not* insert a backslash.
--
-Colin
Technical Details
Message-ID:
<44t7ht$ms2@nyx10.cs.du.edu>Path:
arc1-ca.pugleaf.net!nyx10.cs.du.edu!not-for-mailReferences:
<44qg8v$s1m@ixnews2.ix.netcom.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nyx10.cs.du.edu!not-for-mail From: colin@nyx10.cs.du.edu (Colin Plumb) Newsgroups: comp.std.c Subject: Re: Maximum length of line of C code Date: 3 Oct 1995 23:54:05 -0600 Organization: University of Denver, Dept. of Math & Comp. Sci. Message-ID: <44t7ht$ms2@nyx10.cs.du.edu> References: <44qg8v$s1m@ixnews2.ix.netcom.com> NNTP-Posting-Host: nyx10.cs.du.edu