• 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: gcc poison, how to catch use of strcpy()?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc poison, how to catch use of strcpy()?


  • Subject: Re: gcc poison, how to catch use of strcpy()?
  • From: Gwynne Raskind <email@hidden>
  • Date: Wed, 20 May 2009 10:42:19 -0400

On May 20, 2009, at 8:09 AM, John Cebasek wrote:
Hi Guys:

This has caught my eye. If we were to take the "MyDeprecations.h" route, where's the best place to put the header file that contains the deprecations so that it survives across Xcode updates and requires minimum changes to new and existing projects?

$ sudo /usr/bin/install -c -d -m 0644 -o root -g wheel /path/to/ MyDeprecations.h $HOME/MyDeprecations.h


Or, in non-Terminal speak, drop it in include inside your home directory. The only thing that'll ever overwrite it there is a system reinstall. Downside: You'll have to specifically add the include path to Xcode in each project you use it in. Which Xcode will do automatically for you if you add the header to the project.

-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."

On 19-May-09, at 2:16 PM, Gwynne Raskind wrote:
On May 19, 2009, at 1:04 PM, Sean McBride wrote:
Ever wished Apple would deprecate things so that you'd be warned
against using them?

/*
* only certain compilers support __attribute__((deprecated))
*/
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) &&
(__GNUC_MINOR__ >= 1)))
#define DEPRECATED_ATTRIBUTE __attribute__((deprecated))
#else
#define DEPRECATED_ATTRIBUTE
#endif

/*
* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED
*
* Used on functions introduced in Mac OS X 10.0,
* and deprecated in Mac OS X 10.0
*/
#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED
DEPRECATED_ATTRIBUTE
Is your suggestion to hack the system headers to add the deprecated
decoration?  I guess that would work.
It would work, but it's *very* ugly, and would have to be repeated across every platform and SDK (Mac OS X: 10.3.9, 10.4, 10.5. iPhone: 2.0, 2.1, 2.2, 2.21.) - and don't copy stdio.h between them because it might be different.

Here's a better solution: Take all the identifiers you want to deprecate. Copy their delcarations *verbatim* out of the header in which they're defined. Create a new header file that duplicates those declarations, adding the DEPRECATED_ATTRIBUTE to them. Include that file in the prefix for your project (AFTER all the other includes!). For example, to deprecate strcpy() and sprintf(), you would have a header "MyDeprecations.h" (or whatever) containing these declarations:

// Original declarations taken from stdio.h and string.h in MacOSX10.5.sdk and iPhoneOS2.2.1.sdk
char *strcpy(char *, const char *) DEPRECATED_ATTRIBUTE;
int sprintf(char * __restrict, const char * __restrict, ...) __DARWIN_LDBL_COMPAT(sprintf) DEPRECATED_ATTRIBUTE;


System headers tend to change very little between SDKs at the BSD level, even between MacOS and iPhoneOS, so you shouldn't run into many (if any) conflicts in definitions if you use the header with multiple SDKs.
_______________________________________________
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


References: 
 >gcc poison, how to catch use of strcpy()? (From: "Sean McBride" <email@hidden>)
 >Re: gcc poison, how to catch use of strcpy()? (From: Shawn Erickson <email@hidden>)
 >Re: gcc poison, how to catch use of strcpy()? (From: "Sean McBride" <email@hidden>)
 >Re: gcc poison, how to catch use of strcpy()? (From: Gwynne Raskind <email@hidden>)
 >Re: gcc poison, how to catch use of strcpy()? (From: John Cebasek <email@hidden>)

  • Prev by Date: Re: gcc poison, how to catch use of strcpy()?
  • Next by Date: Xcode Linker
  • Previous by thread: Re: gcc poison, how to catch use of strcpy()?
  • Next by thread: Re: gcc poison, how to catch use of strcpy()?
  • Index(es):
    • Date
    • Thread