Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any CW mach-o success stories out there?



on 2002/05/22 12:09 pm, George Varga wrote:

> - some using std::XXX must be bracketed #if !qCarbonMachO
> - some direct use of the std::XXX must be either changed to "using
> std::XXX" in the beginning of the file or should be changed to XXX

There is another solution to this. The problem arises because MSL headers
(like <cstring>) include Apple's libc headers when targeting Mach-O, and the
libc headers are not wrapped inside a 'namespace std'. So I put the
following in my prefix file:

namespace std
{
using ::memset;
using ::memchr;
using ::memcmp;
using ::memcpy ;
using ::memmove;
using ::strlen;
using ::strcpy;
using ::strncpy;
using ::strcat ;
using ::strncat;
using ::strcmp ;
using ::strncmp;
using ::strcoll;
using ::strxfrm;
using ::strchr ;
using ::strrchr;
using ::strpbrk;
using ::strspn ;
using ::strcspn;
using ::strtok ;
using ::strstr;
using ::strerror;
// etc.
}

Then I can reference std::XXX wherever I want, either directly or with a
using std::XXX.

I chose this approach because I expect the MSL problem will go away quite
soon (I haven't checked CW8 yet, but I heard that they were going back to
using their own libc implementation) and I don't want to mess up my sources
unnecessarily. In particular, I don't want to put 'using' declarations in my
header files when I have methods that take arguments with std:: types or
have inline methods that use std:: functions. MSL correctly implements
Standard C++ for CFM-Carbon, so I prefer to keep my sources compatible with
the standard.

--Neil

Neil Mayhew
Calgary, Alberta, Canada
_______________________________________________
macapp-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macapp-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Any CW mach-o success stories out there? (From: George Varga <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.