Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 23 Dec 2011 04:49:43 -0600 Message-ID: <4EF45CC7.7759@mindspring.com> Date: Fri, 23 Dec 2011 05:49:43 -0500 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: warning: string length greater than '509' References: Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Lines: 56 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.156.228.164 X-Trace: sv3-v6fO4/DMxihVDSe0WtnNNXw0OZn47NpS4/U/7TZwhFrASfYaU7aZhE4meqLN8iVsim3YYRRzsVKTbfe!ZFa1I9Z4oOHToslFKcHDsfmzwCNTBQZotRCgA1pKGWCH/2jzwurGWMjFUUYTuBkC/LpmxJP/w1Rz!D1u1D3j9DiY= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3045 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:14903 JohnF wrote: > > I like to compile (linux/gcc) with -pedantic -Wall > and neaten up the code to eliminate all warnings. > But the following code emits the message > warning: string length '1008' is greater than the > length '509' ISO C90 compilers are required to support > and I can't see a neat way around it. The offending > statement is, > static char latexwrapper[16384] = > "\\documentclass[10pt]{article}\n" > "\\usepackage[latin1]{inputenc}\n" > "\\usepackage{amsmath}\n" > "\\usepackage{amsfonts}\n" > "...lots-more-junk..."; > I could obviously break it up into several smaller > initializations and strcat() them all at runtime, > but that (in my opinion) isn't what I meant by "neat". > It works as is, which is how I'd leave it if that's > (strcat() several smaller strings at runtime) is the > only solution. But a straightforward way around the > warning would be even nicer. Using strcat might only have the effect of avoiding the warning, while retaining the portability problem, which may or may not be acceptable to you. If you actually want the portability that the warning is reffering to, and if latexwrapper is supposed to be constant, and all that you are ever going to do with it, is to write it to a file or to files such as standard output for example, then you might try something like static char latexwrapper[33][510] = /* {"",""} */ and use fputs in a loop to do write operations on 33 strings of acceptable length. The number (509) appears more than once in the C90 standard in a related context. ISO/IEC 9899: 1990 7.9.6 Formatted input/output functions 7.9.6.1 The fprintf function Environmental limit The minimum value for the maximum number of characters produced by any single conversion shall be 509. G.2 Undefined behavior — A single conversion by the fprintf function produces more than 509 characters of output (7.9.6.1). -- pete