Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!nike!cad!ucbvax!decvax!tektronix!uw-beaver!uw-june!entropy!dataio!bright From: bright@dataioDataio.UUCP (Walter Bright) Newsgroups: net.lang.c Subject: Re: Error recovery (long) Message-ID: <1009@dataioDataio.UUCP> Date: Thu, 29-May-86 13:15:51 EDT Article-I.D.: dataioDa.1009 Posted: Thu May 29 13:15:51 1986 Date-Received: Tue, 3-Jun-86 20:54:52 EDT References: <312@uw-nsr.UUCP> Reply-To: bright@dataio.UUCP (Walter Bright Distribution: net Organization: Data I/O Corp., Redmond WA Lines: 22 In article <312@uw-nsr.UUCP> john@uw-nsr.UUCP (John Sambrook) writes: >While on the subject of compilers, I would like to share two other features >of this compiler that I find useful. >The second feature is the ability to declare certain data structures as >"read only." This is done via a compiler switch "-R" and applies to all >data structures that are initialized to a constant value within the >compilation unit. > > int a = 1; /* "read only" */ > main() { > int b; /* "read / write" */ > > b = a; /* this is legal */ > a = 2; /* this is not */ > } The declaration for a can be made 'read only' by declaring it as follows: const int a = 1; Doing an assignment to a will then cause a syntax error when compiling. This is in the draft ANSI C spec.