Next: , Previous: Comments, Up: Writing C


5.3 Clean Use of C Constructs

See Syntactic Conventions.

Do not attempt to put more than 509 bytes into a single string in your printf calls. The `509' is taken from the ANSI C standard, and reflects unfortunate limits in old-fashioned implementations. The actual portable limit is considerably larger these days, but it's wise not to go overboard. In particular, PDP-11 V7 Unix, MS-DOS and Xenix MSC, Bruker X32 SYSV3.0 compilers have this problem.

This is a stringent condition, as many wouldn't trust themselves to remember to count the characters in the long strings every time an option is added, the grammar changed, or a typo fixed in a `--help' message. I think there are enough long `--help' messages to merit an automated approach to keeping string lenghts under that limit. If avoiding strings longer than 509 characters is that important, perhaps gcc should be able to warn about it (letter from Jim, 1994-03-31). The msgfmt program provides an indirect way to check the length of many strings (letter from Ulrich, 1996-09-17).