home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13244 < prev    next >
Encoding:
Internet Message Format  |  1992-09-02  |  1.8 KB

  1. Path: sparky!uunet!cs.utexas.edu!rutgers!modus!polluce!siap.sublink.org!aleardo
  2. From: morgaine@siap.sublink.org (Nadia Pitacco (Morgaine))
  3. Newsgroups: comp.lang.c++
  4. Subject: Name space of enumeration lists identifiers
  5. Keywords: enumeration name space
  6. Message-ID: <aleardo.715356862@siap.sublink.org>
  7. Date: 1 Sep 92 14:14:22 GMT
  8. Sender: news@siap.sublink.org
  9. Reply-To: morgaine@siap.sublink.org
  10. Organization: SIAP Sistemi S.p.A.
  11. Lines: 45
  12. Nntp-Posting-Host: gea
  13.  
  14.  
  15. I have the following source file:
  16.  
  17.         #include <pwd.h>
  18.         enum my_enum {comment, some_other_value};
  19.         
  20.         main () {
  21.             /* code omitted */
  22.         exit (0);
  23.         }
  24.     
  25. pwd.h includes the definition of the following struct:
  26.  
  27.      struct comment {
  28.          char    *c_dept;
  29.          char    *c_name;
  30.          char    *c_acct;
  31.          char    *c_bin;
  32.      };
  33.         
  34. Compilation under ObjectWorks, which includes a modified version of At&T cfront, produces the following results:
  35.  
  36.     CC  /tmp/main.c:
  37.     "/tmp/main.c", line 2: error: syntax error
  38.     "/tmp/main.c", line 2: error: syntax error
  39.     "/tmp/main.c", line 2: error: bad declaration of some_other_value -- 
  40.     did you forget a ';'?
  41.     3 errors
  42.    
  43. While both Liant C++ compiler and g++ rev.1.39 (with option -Wall) do not
  44. produce any error or warning message.
  45.  
  46. According to "The Annotated C++ Reference Manual" (p. 27)
  47. "A name s can be declared as a type and as a non-type in a single scope."
  48. and I though that identifiers in an enumerator list belonged to the same 
  49. name space of constants. 
  50.  
  51. Who is wrong, and why?
  52.                                              Nadia Pitacco
  53. -- 
  54.     ------------------------------------------------------------
  55.     -  Nadia Pitacco                 SIAP Sistemi S.p.A.       -
  56.     -  via Mercantesse 3 - 20021 Baranzate Milano ITALY        -
  57.     -  E-Mail: morgaine@siap.sublink.org                       -
  58.