Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Inline functions

Inline functions

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dy
    wrote on last edited by
    #1

    I've just found this in some code I've been given to maintain:

    inline char * _fstrchr(const char *szStr, char ch)
    {
    return strchr(szStr, ch);
    }

    It's in a .h file, and it's used all over the place. Is there any benefit with this function over using strchr directly? I thought inlined functions basic replaced the _fstrchr token with the content of the function - as the function is not doing anything else, is there any point?


    - Dy

    M 1 Reply Last reply
    0
    • D Dy

      I've just found this in some code I've been given to maintain:

      inline char * _fstrchr(const char *szStr, char ch)
      {
      return strchr(szStr, ch);
      }

      It's in a .h file, and it's used all over the place. Is there any benefit with this function over using strchr directly? I thought inlined functions basic replaced the _fstrchr token with the content of the function - as the function is not doing anything else, is there any point?


      - Dy

      M Offline
      M Offline
      Maxwell Chen
      wrote on last edited by
      #2

      -Dy wrote:

      thought inlined functions basic replaced the _fstrchr token

      He used this token, _fstrchr, in the entire source. There's a benefit from this way:   Some time later when there is a need to alter the implementation, he only needs to modify one line, instead of using the text search function to find out all the occurrences of strchr. Similar concept as: #ifdef UNICODE #define _tcscpy strcpyW #else #define _tcscpy strcpyA #endif


      Maxwell Chen

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups