Thread: #define private public

  1. #16
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Originally posted by Omnius
    ...if the C++ standard does forbid the redefinition of keywords using macros...
    It doesn't.

    gg

  2. #17
    Registered User
    Join Date
    Sep 2003
    Posts
    135
    From 17.4.3.1.1:

    "Nor shall such a translation unit define macros for names lexically identical to keywords."

  3. #18
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Why attempt to fool readers by quoting the standard out of context?

    17 - 1
    This clause describes the contents of the C++ Standard Library, how a well-formed C++ program makes use of the library, and how a conforming implementation may provide the entities in the library.
    gg

  4. #19
    Registered User
    Join Date
    Sep 2003
    Posts
    135
    Originally posted by Codeplug
    Why attempt to fool readers by quoting the standard out of context?



    gg
    Please don't try to make out that I'm trying to fool people, Codeplug. Feel free to refute what I said if you're able to, in which case I'll acknowledge it. At the moment, I don't see what you're trying to prove with your quote. It appears to me you simply reinforce what I've said. Your quote is consistent with what I said about the use of macros to redefine C++ keywords being ill-formed.

    Either I'm correct, or I'm wrong. There's no attempt to fool people. That's just offensive nonsense on your part.

  5. #20
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    This has appropriate context and is self-explanatory:
    Code:
      17   Library introduction                                [lib.library]
    ...
      17.3  Library-wide requirements                     [lib.requirements]
        1 This subclause specifies requirements that apply  to  the  entire  C++
          Standard library. ...
    ...
      17.3.3  Constraints on programs                      [lib.constraints]
        1 This subclause describes restrictions on C++  programs  that  use  the
          facilities  of  the  C++  Standard  library. ...
    ...
      17.3.3.1  Reserved names                          [lib.reserved.names]
    ...
      17.3.3.1.1  Macro names                              [lib.macro.names]
    
    1 Each name defined as a macro in a header is reserved to the  implemen-
      tation for any use if the translation unit includes the header.21)
    
    2 A translation unit that includes a header shall not contain any macros
      that  define names declared or defined in that header.  Nor shall such
      a translation unit define macros for names lexically identical to key-
      words.
    This is ok. [EDIT] maybe not...sounded good at the time. [/EDIT]
    Code:
    #include <string>
    #define string wstring // search and replace broken :(
    This breaks requirement 17.3.3.1.1 - 2 for using the C++ Standarnd Library.
    Code:
    #define private public
    #define basic_string my_basic_string
    #include <string>
    [EDIT]
    Anyways, there's nothing that says a compiler shouldn't compile the above code.
    Chapter 16
    defines how a compiler should treat preprocessing directives.
    [/EDIT]

    gg

    quotes not from the final draft standard
    Last edited by Codeplug; 12-19-2003 at 09:42 PM.

  6. #21
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Where did you get the Standard from? What is the cheapest legal way to obtain it?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #22
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You can buy the final standard at the ISO Store.

    However the final draft is free, and you can find sites that sum up the changes/differences between the two.

    You can download a PDF version here.

    Online version.

    You can also google ISO/IEC 14882 and find some other sources.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading Process Memory
    By polydegmon in forum C# Programming
    Replies: 0
    Last Post: 05-26-2009, 07:18 AM
  2. Help me with function call
    By NeMewSys in forum C++ Programming
    Replies: 16
    Last Post: 05-22-2008, 01:53 PM
  3. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  4. LISP (DrScheme) any one?
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 03-31-2004, 12:52 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM