This is for an iPhone application, using ObjC code with access to C-level functions and primitive data types.The original primitive types are either double, float, sci notiation(E) or unsigned int. So there's a lot of: #define de2ra 1.74532925E-2 // Degrees to Radians. #define pi 3.1415926535898 // Pi.
I had thought using static const vs #define would be more-efficient for computing & storage... ... so I've read. But if #define is efficient enough, it's easier just to keep the #define statements. Ric. On Mon, Sep 21, 2009 at 2:27 PM, Jens Alfke <j...@mooseyard.com> wrote: > > On Sep 21, 2009, at 2:15 PM, Frederick C. Lee wrote: > > I'm assuming 'const <datatype>' is better then the compiler directive >> '#define', due to the use of the compiler >> for more-efficient code. Hence the attempt. >> > > It depends. In C, a const variable of a primitive type like an integer is > less efficient than a #define. The problem is that it ends up being treated > as a regular global variable (except its value can't be changed). In C++, > though, const primitives are optimized away just as a #define would be, and > can be declared without an 'extern' in a header. > > (If you want, you can get the C++ semantics by using Objective-C++, i.e. > changing the suffix of your source files to .mm.) > > —Jens _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com