From: lmauro AT scientist DOT com (Leo Mauro) Subject: RE: bool and gcc 11 Aug 1998 07:52:07 -0700 Message-ID: <000401bdc4e2$e8baef60$1e6e31cf.cygnus.gnu-win32@leo-nt.rd.telesystech.com> References: <3 DOT 0 DOT 1 DOT 32 DOT 19980810163711 DOT 0069a178 AT friko6 DOT onet DOT pl> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit To: On Monday, August 10, 1998 10:37 AM, Inquisitor Nikodemus wrote: > Does gcc (egcs exactly) support boolean (bool) type? Yes. > What does the following mean ? > > .cc:120: warning: name lookup of `index' changed for new ANSI `for' scoping > .cc:119: warning: using obsolete binding at `index' > > What's that "new ANSI 'for' scoping" ? Old (pre final ANSI standard) 'for' scoping made the following snippet valid: for (int i = 0; i < N; i++) { // Use i inside the 'for' block } // Use i outside the 'for' block I.e., it meant that a variable introduced and declared in the initialization part of the 'for' statement would be valid after the 'for' (until the end of the block enclosing the 'for' statement). The new ANSI scoping rules make 'i' unavailable outside of the 'for' statement body. To accomodate the large amount of code that relies on the old scoping, the compiler takes extra pains to detect and allow this usage (with warnings to induce the code writer to change it). A standards-compliant workaround would be: { int i; for (i = 0; i < N; i++) { // Use 'i' inside the 'for' block } // Use 'i' outside the 'for' block } // 'i' is no longer available here where the outer braces limit the variable scope (a good idea). Or just drop the outer braces to get the pre-standard scope. > And the next one : > _x.cc:122: request for member `figure' in `nodebufstat', which is of > non-aggregate type `node *' > > Line 122 is : *(nodebufstat).figure=-1 ; [SNIP] Your line, fully parenthesized to take into account operator precedence would look: (*((nodebufstat).figure)) = -1; In other words, '.' is more binding than '*'. Therefore, in your code, '.' is trying to find the 'figure' member in 'nodebufstat', and then tries to apply the '*' indirection to the member's value. First of all, 'nodebufstat' is not an aggregate (structure, union or class) but a pointer to such. And second, the 'figure' member is not a pointer. The compiler is, thankfully, stopping at the first error instead of producing a cascade. A corrected line would be (*nodebufstat).figure = -1; or, as is the customary way: nodebufstat->figure = -1; remembering that a->b is always equivalent to (*a).b where 'a' must be an expression that evaluates to a pointer to an aggregate that has 'b' as a member. Bot '.' and '->' have the same precendence and bind left to right. Leo Mauro Principal Scientist TeleSys Technologies, Inc. - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".