home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18717 < prev    next >
Encoding:
Text File  |  1993-01-05  |  4.0 KB  |  83 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Standard library functions and macros
  5. Message-ID: <1993Jan5.185023.3646@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1992Dec29.213548.5661@microsoft.com> <9300302.725@mulga.cs.mu.OZ.AU> <1993Jan2.191336.28542@taumet.com> <1993Jan04.231519.8704@microsoft.com>
  8. Date: Tue, 5 Jan 1993 18:50:23 GMT
  9. Lines: 72
  10.  
  11. jimad@microsoft.com (Jim Adcock) writes:
  12.  
  13. >How about implementations and programmers that want to continue to
  14. >share code between C and C++ implementations?  Let's say a program
  15. >that it created from some "C" files and some "C++" files, and each of
  16. >these files in turn calls some of the standard-C functions.  How are
  17. >you going to make this work?  Seems to me you are requiring 
  18. >"C++ calling convention" of the standard-C functions called by the
  19. >C++ files, whereas the standard-C functions called from the "C" files
  20. >would have to follow "C" calling convention.
  21.  
  22. Not at all.  The C++ implementation is allowed to use C linkage for the
  23. C library functions.  It is merely not required to do so.
  24.  
  25. >At the very least this
  26. >seems to me to be saying that you're requiring dual-entry stubs of
  27. >all the library functions.  And then how do these things coexist in
  28. >one library and get linked in correctly?  Can you point to even one
  29. >existing implementation that implements your proposed changes, and
  30. >which continues to allow mixed Cfile/C++file programs to be compiled and linked?
  31.  
  32. There is not and never was any claim that you can choose any C and any
  33. C++ implementation arbitrarily and create a mixed program.  The compilers
  34. have to agree on a number of implementation details.  If a C++
  35. implementation isn't compatible with the C implementation you intend to
  36. use, don't buy it.
  37.  
  38. The existence proof you requested:  My company provides a mixed C/C++
  39. implementation (Oregon C++).  We arrange things so that code compiled
  40. with our compiler in either C or C++ mode can be mixed with code
  41. compiled with the "native" C compiler for the OS.  You can also mix C
  42. code compiled with the native headers and the native compiler with code
  43. compiled with our headers and our compiler (in any mixture of C and C++).
  44. Our headers use inline functions for some functions which are macros in
  45. the native C headers, and even contain code along these lines:
  46.     #if __cplusplus
  47.     inline T somefunc(args) { ... }
  48.     #else
  49.     #define somefunc(args) ...
  50.     #endif
  51. This kind of thing simply isn't a problem.
  52.  
  53. If you write standard-conforming source code, you can use the C code
  54. as C++ code provided you also follow the C++ rules.  Examples:  A
  55. strictly-conforming C program need not declare certain kinds of
  56. functions, or may provide non-prototype declarations.  This won't work
  57. for C++; you have to provide prototypes.  A strictly-conforming C
  58. program may assume that sizeof('a')==sizeof(int); you may not make this
  59. assumption in C++.  A strictly-conforming C program may use identifiers
  60. with the names "class" or "virtual"; a C++ program may not.
  61.  
  62. A new C++ rule is that for portability you should include standard headers
  63. rather than declaring the standard functions yourself.  We can argue
  64. about whether this constitutes an unacceptable burden on the programmer.
  65. The C++ committee concluded it did not, after careful consideration for
  66. over a year by many people.  If you disagree, it would help to supply
  67. some sort of statistics or even a survey to back up your opinion.
  68.  
  69. >|A few weeks ago I asked for analyses of this situation, or of any other
  70. >|problem associated with the change in C library rules for C++.  I did
  71. >|not get any response.  I renew the request.  If the Committee has made
  72. >|a bad decision, this is the time to correct it.
  73.  
  74. >Consider my arguments here as a response to your request.
  75.  
  76. Posting to this newsgroup is not a submission to the C++ committee.
  77. Your organization is a member of the committee; write a concrete
  78. proposal (i.e., specific changes to the Working Paper) and give it
  79. to one of your representatives.
  80. -- 
  81.  
  82. Steve Clamage, TauMetric Corp, steve@taumet.com
  83.