title: What is the right way to inline functions?
body: <p>I'm trying to make a game debugger with limited warnings (if possible no warnings and suppressed warnings).</p>
  <p>While creating a message interface class, I kept getting this warning: &quot;Warning C4710 'IMessageA::IMessageA(IMessageType,size_t,const char *,...)': function not inlined Game Logger    Game Logger\Source.cpp 256&quot;</p>
  <p>I know I could suppress the warning, but I would prefer to fix it then suppress it. I tried &quot;__forceinline&quot;, &quot;__inline&quot;, and &quot;inline&quot; but the compiler warning didn't go away.</p>
  <pre><code>enum class IMessageType
  {
      IMessageType_Message,
      IMessageType_Info,
      IMessageType_Warning,
      IMessageType_Debug,
      IMessageType_Error,
      IMessageType_FatalError
  };
  
  enum class IMessageSource
  {
      IMessageSource_None,
      IMessageSource_User,
      IMessageSource_Internal,
      IMessageSource_External,
      IMessageSource_Unknown
  };
  
  class IMessageA : public std::string
  {
  public:
      
      IMessageA(IMessageType Type, IMessageSource Source, const char* Caller, const char* File,
          const char* Func, int Line, size_t Words, const char* Format, ...)
      {
          _Type = Type;
          const char* MessageType = FormatMessageType(_Type);
          _Source = Source;
          const char* MessageSource = FormatMessageSource(_Source);
          _Caller = Caller;
          _File = File;
          _Func = Func;
          _Line = Line;
          time_t MessageTime = 0;
          time(&amp;MessageTime);
          tm MessgeDateStamp = { 0 };
          localtime_s(&amp;MessgeDateStamp, &amp;MessageTime);
          char MessageTimeStamp[26] = { 0 };
          asctime_s(&amp;MessageTimeStamp[0], 26, &amp;MessgeDateStamp);
          std::unique_ptr&lt;char[]&gt; FormattedMessage = std::make_unique&lt;char[]&gt;(Words + 1);
          va_list _Args = nullptr;
          __crt_va_start(_Args, Format);
          _vsnprintf_s(FormattedMessage.get(), Words, Words, Format, _Args);
          _Args = nullptr;
          this-&gt;operator+=(&quot;[&quot;);
          this-&gt;operator+=(&amp;MessageTimeStamp[0]);
          this-&gt;pop_back();
          this-&gt;operator+=(&quot;][&quot;);
          if (MessageSource != nullptr)
          {
              this-&gt;operator+=(&amp;MessageSource[0]);
          }
          if (MessageSource != nullptr &amp;&amp; _Caller != nullptr)
          {
              this-&gt;operator+=(&quot;: &quot;);
          }
          if (_Caller != nullptr)
          {
              this-&gt;operator+=(_Caller);
              this-&gt;operator+=(&quot;][&quot;);
          }
          this-&gt;operator+=(MessageType);
          this-&gt;operator+=(&quot;] &quot;);
          if (_Func != nullptr)
          {
              this-&gt;operator+=(_Func);
              this-&gt;operator+=(&quot; - &quot;);
          }
          if (_File != nullptr)
          {
              this-&gt;operator+=(_File);
              this-&gt;operator+=(&quot;: &quot;);
          }
          if (_Line != 0)
          {
              this-&gt;operator+=(&quot;Line: &quot;);
              this-&gt;operator+=(std::to_string(_Line));
              this-&gt;operator+=(&quot; - &quot;);
          }
          if (FormattedMessage != nullptr)
          {
              this-&gt;operator+=(FormattedMessage.get());
          }
          FormattedMessage.release();
      }
      IMessageA(IMessageType Type, size_t Words, const char* Format, ...)
      {
          _Type = Type;
          const char* MessageType = FormatMessageType(_Type);
          time_t MessageTime = 0;
          time(&amp;MessageTime);
          tm MessgeDateStamp = { 0 };
          localtime_s(&amp;MessgeDateStamp, &amp;MessageTime);
          char MessageTimeStamp[26] = { 0 };
          asctime_s(&amp;MessageTimeStamp[0], 26, &amp;MessgeDateStamp);
          std::unique_ptr&lt;char[]&gt; FormattedMessage = std::make_unique&lt;char[]&gt;(Words + 1);
          va_list _Args = nullptr;
          __crt_va_start(_Args, Format);
          _vsnprintf_s(FormattedMessage.get(), Words, Words, Format, _Args);
          _Args = nullptr;
          this-&gt;operator+=(&quot;[&quot;);
          this-&gt;operator+=(&amp;MessageTimeStamp[0]);
          this-&gt;pop_back();
          this-&gt;operator+=(&quot;][&quot;);
          this-&gt;operator+=(MessageType);
          this-&gt;operator+=(&quot;] &quot;);
          if (FormattedMessage != nullptr)
          {
              this-&gt;operator+=(FormattedMessage.get());
          }
          FormattedMessage.release();
      }
  private:
      _Check_return_ const char* FormatMessageType(IMessageType Type) noexcept
      {
          switch (Type)
          {
          case IMessageType::IMessageType_Message:
              return &quot;_MSG_&quot;;
          case IMessageType::IMessageType_Info:
              return &quot;_INFO&quot;;
          case IMessageType::IMessageType_Warning:
              return &quot;_WARN&quot;;
          case IMessageType::IMessageType_Debug:
              return &quot;DEBUG&quot;;
          case IMessageType::IMessageType_Error:
              return &quot;ERROR&quot;;
          case IMessageType::IMessageType_FatalError:
              return &quot;FATAL&quot;;
          }
          return &quot;UKNWN&quot;;
      }
      _Check_return_ const char* FormatMessageSource(IMessageSource Source) noexcept
      {
          switch (Source)
          {
          case IMessageSource::IMessageSource_User:
              return &quot;__USER__&quot;;
          case IMessageSource::IMessageSource_Internal:
              return &quot;INTERNAL&quot;;
          case IMessageSource::IMessageSource_External:
              return &quot;EXTERNAL&quot;;
          case IMessageSource::IMessageSource_Unknown:
              return &quot;UNKNOWN_&quot;;
          case IMessageSource::IMessageSource_None:
              return nullptr;
          }
          return nullptr;
      }
  protected:
      IMessageType _Type = IMessageType::IMessageType_Message;
      IMessageSource _Source = IMessageSource::IMessageSource_Internal;
      const char* _Caller = nullptr;
      const char* _File = nullptr;
      const char* _Func = nullptr;
      int _Line = 0;
      long _Reserved = 0;
  };
  </code></pre>
  <p>Not sure if it's important, but I will include some extra data:</p>
  <p>C++ Language Standard: ISO C++20 Standard (/std:c++20)
  C Language Standard: ISO C17 (2018) Standard (/std:c17)
  Warning Level: EnableAllWarnings (/Wall)
  Treat Warnings As Errors: Yes (/WX)
  And I set all of the C++ programmer rule sets to active to make sure I don't miss anything.</p>