Article View: gnu.gcc.help
Article #893unterminated character constant
From: meissner
Date: Wed, 27 Jan 1993 14:37
Date: Wed, 27 Jan 1993 14:37
42 lines
2040 bytes
2040 bytes
| Compiling the following code segment (no compiler options):
|
| #if 0
| This is a test of an if
| This line isn't going to work
| But this line will, as will the first line
| #endif
|
| with GCC 2.3.3 under Linux 0.99pl3 (i486), SunOs 4.1.1 (Sparc), and
| Ultrix 4.2 (DEC 5000) yields an the error:
|
| a.c:3: unterminated character constant
|
| The problem is the single quote. It also happens if you use an #ifdef,
| but doesn't happen if you put the text inside a comment.
This is not a bug. ANSI requires that tokenization occur before
#ifdef processing, in order to describe #ifdef processing in any
reasonable fashion.
In fact, the fine manual says (in the incompatibilities section):
* GNU CC complains about unterminated character constants inside of
preprocessor conditionals that fail. Some programs have English
comments enclosed in conditionals that are guaranteed to fail; if
these comments contain apostrophes, GNU CC will probably report an
error. For example, this code would produce an error:
#if 0
You can't expect this to work.
#endif
The best solution to such a problem is to put the text into an
actual C comment delimited by `/*...*/'. However, `-traditional'
suppresses these error messages.
--
Michael Meissner email: meissner@osf.org phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
You are in a twisty little passage of standards, all conflicting.
Technical Details
Message-ID:
<9301271435.AA05272@tiktok.osf.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!canrem!telly!utzoo!torn!cs.utexas.edu!sdd.hp.com!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!osf.ORG!meissnerReferences:
meissner@osf.ORGShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!canrem!telly!utzoo!torn!cs.utexas.edu!sdd.hp.com!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!osf.ORG!meissner From: meissner@osf.ORG Newsgroups: gnu.gcc.help Subject: unterminated character constant Date: 27 Jan 1993 09:37:35 -0500 Organization: GNUs Not Usenet Lines: 42 Sender: daemon@cis.ohio-state.edu Distribution: gnu Message-ID: <9301271435.AA05272@tiktok.osf.org> References: meissner@osf.ORG