home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 17832 < prev    next >
Encoding:
Text File  |  1992-12-11  |  1.8 KB  |  58 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!laphroaig!cflatter
  3. From: cflatter@nrao.edu (Chris Flatters)
  4. Subject: Re: Name-scope semantic differences between 2.
  5. Message-ID: <1992Dec11.213637.26641@nrao.edu>
  6. Sender: news@nrao.edu
  7. Reply-To: cflatter@nrao.edu
  8. Organization: NRAO
  9. References: <1992Dec11.181927.7768@delfin.com>
  10. Date: Fri, 11 Dec 1992 21:36:37 GMT
  11. Lines: 45
  12.  
  13. In article 7768@delfin.com, mr@delfin.com (Mark Rosenberg) writes:
  14. >How are CFRONT 2.1 name-scoping semantics different from CFRONT 3.0
  15. >name-scoping semantics? We are developing a product that needs to be
  16. >supported on several different platforms (currently RS-6000 and Sparc).
  17. >This product relies upon Objectstore. According to their support
  18. >people, their compiler has templates but 2.1 name-scope semantics.
  19. >
  20. >Apparently 2.1 name-scope semantics are not a subset of 3.0 name-scope
  21. >semantics. What are the implications of these semantic differences?
  22. >What should one do or not do to maximize compatibility?
  23.  
  24. Suppose that you declare a nested class as follows.
  25.  
  26. class foo
  27.     {
  28.     ...
  29.     class bar
  30.     {
  31.     ...
  32.     }
  33.     }
  34.  
  35. According to the ARM the scope of bar is limited to class foo.  cfront
  36. 3.0 and g++ 2.x conform to this.
  37.  
  38. cfront 2.1 gives bar global scope.  To clarify this the definition of
  39. a constructor for bar would look like this according to the ARM
  40.  
  41. foo::bar::bar() { ... }
  42.  
  43. but would look like this for cfront 2.1
  44.  
  45. bar::bar() {...}
  46.  
  47. To maximise portability between cfront 2.1 and other C++ compilers you can either
  48.  
  49. 1 - avoid using nested classes or
  50.  
  51. 2 - ensure that class names are unique at the innermost scope level (ie.
  52.     make sure that you don't have two or more nested classes with the same
  53.     name) and use the preprocessor to fix up member function definitions.
  54.  
  55.     Chris Flatters
  56.     cflatter@nrao.edu
  57.  
  58.