Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5989595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:07:27+00:00 2026-05-22T23:07:27+00:00

I was poking around the definitions for things like CGPoint for hints on how

  • 0

I was poking around the definitions for things like CGPoint for hints on how to create my own functions but I don’t know the purpose of CG_INLINE. What is happening behind the scenes here?

CG_INLINE CGPoint
CGPointMake(CGFloat x, CGFloat y)
{
  CGPoint p; p.x = x; p.y = y; return p;
}

CG_INLINE CGSize
CGSizeMake(CGFloat width, CGFloat height)
{
  CGSize size; size.width = width; size.height = height; return size;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:07:28+00:00Added an answer on May 22, 2026 at 11:07 pm

    Inline functions are compiled into the call site, rather than being compiled as a single block of function code and call instructions issued when the function is used. With care, this provides a little more speed and greater numbers of cache hits. However, the history of inline in C and C++ is rocky, so this macro effectively provides a compiler independent static inline behaviour. Looking at the definition:

    #if !defined(CG_INLINE)
    # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #  define CG_INLINE static inline
    # elif defined(__MWERKS__) || defined(__cplusplus)
    #  define CG_INLINE static inline
    # elif defined(__GNUC__)
    #  define CG_INLINE static __inline__
    # else
    #  define CG_INLINE static    
    # endif
    #endif /* !defined(CG_INLINE) */
    

    So…

    1. For compilers providing __STDC_VERSION__ of an appropriate version (in this case >= C99), this means static inline (as C99 allows this natively)
    2. Similarly for Metrowerks Codewarrior or C++ compilers, which support inline natively.
    3. For GCCs not supporting C99, it resolves to static __inline__. The use of __inline__ is the GCC specific inline specifier for previous C standards where inline is unsupported : http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Alternate-Keywords.html.
    4. If all of these fail, it doesn’t bother with inline – it’s just static.

    Why bother with all of these definitions? Because Apple, in their history, have been through a fair few compilers. In the days of yore, the Codewarrior C compiler was the tool of choice for users. Since OS X, Apple have been using Objective C and C++ via an (originally modifier) GCC. Recently, they’re transitioning to clang. This macro covers all the cases (and, given how new Core Graphics is, I suspect is a modified version of an older macro).

    However, many compilers will ignore inline annotations these days, as their optimisers are better than the hints provided by the programmer. In your own code, don’t bother with it (in native form, or via this macro) unless you’re really sure you need it (and have proven it useful via profiling). Of course, you may still want static – the above advice covers the inline behaviour.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to javascript/jquery and I've done some poking around the web, but I
This is kinda oddball, but I was poking around with the GNU assembler today
I was poking around in .NET Reflector, and noticed that for reference types like
Whilst poking around some code using a .NET Reflector for an app I don't
Been poking around google and haven't found any like what I'm after. so what
Alright, so I've been doing some poking around, and I realize my problem, but
So I've been poking around with C# a bit lately, and all the Generic
I've recently started poking around in Visual Studio 2005, and I'm mucking about in
I'm poking around with jQuery and the fadeIn & fadeOut effects. I have the
Although I'm still poking around in the docs and online, I figured I'd ask

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.