Thread: Restricting pointers on inline functions

  1. #1
    Registered User
    Join Date
    May 2016
    Posts
    104

    Restricting pointers on inline functions

    Hey guys,
    I was wondering on the effects of using "restrict" on the parameters of inline functions. I would assume since the function will -presumably- be inlined, its parameters will be ignored and replaced with locals. If so, I'd be inclined to believe the locals are a better match for "restrict" and there is no use in restricting the function parameters.
    On the other hand if for whatever reason the compiler decides not to inline the function, the restrict qualifier will be of significance.

    Am I incorrect in my assumptions? Will using restrict have an adverse effect under these circumstances?

    Thanks.

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,626
    The restriction is useful in either case. If the function is inlined it will still create its own block and the pertinent compiler optimizations will still be useful. You can use restrict in a block of code; it's not only useful for function parameters. So if restrict is actually useful on your function parameters and you manually inline the code, then you should create a block and define your "local" pointers as restricted.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  3. #3
    Registered User
    Join Date
    May 2016
    Posts
    104
    That is good to hear xD.
    Thank you! ��

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Q about inline functions
    By homer_3 in forum C Programming
    Replies: 3
    Last Post: 05-26-2011, 03:44 AM
  2. Inline functions
    By Sharke in forum C++ Programming
    Replies: 6
    Last Post: 05-13-2009, 06:18 AM
  3. Inline Functions
    By EvilGuru in forum C Programming
    Replies: 4
    Last Post: 11-07-2005, 04:03 PM
  4. Inline functions
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 08-06-2002, 03:35 AM
  5. What should I really use inline functions?
    By GrNxxDaY in forum C++ Programming
    Replies: 6
    Last Post: 07-27-2002, 04:49 PM

Tags for this Thread