• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Refactoring a #define definition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Refactoring a #define definition


  • Subject: Re: Refactoring a #define definition
  • From: Carl Hoefs <email@hidden>
  • Date: Sat, 25 Jul 2015 12:29:05 -0700


On Jul 25, 2015, at 11:03 AM, Quincey Morris <email@hidden> wrote:

On Jul 25, 2015, at 10:37 , Carl Hoefs <email@hidden> wrote:

Effectively, what the compiler does with a #define _is_ a global replace.

It’s not, though. Not in general.

1. It’s not global. A #define can be undefined and redefined.

2. It’s not unique. IIRC, the appearance of the define symbol inside its own definition is *not* subject to macro expansion.

3. Macro expansion happens as a separate lexical pass over the input. For example, if source lines are not compiled as a result of a define/if then it’s not clear what replacement might be suitable at refactoring. Or again, token pasting may simply produce incorrect results if macro names are arbitrarily changed around them.

Yes, your point 3 is primarily what I hadn't considered. 
-Carl


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Refactoring a #define definition
      • From: Michael David Crawford <email@hidden>
References: 
 >Re: Refactoring a #define definition (From: Carl Hoefs <email@hidden>)
 >Re: Refactoring a #define definition (From: Quincey Morris <email@hidden>)

  • Prev by Date: matching brace not found
  • Next by Date: Re: Refactoring a #define definition
  • Previous by thread: Re: Refactoring a #define definition
  • Next by thread: Re: Refactoring a #define definition
  • Index(es):
    • Date
    • Thread