Menu

Format strings and class templates

CHR
2020-12-10
2020-12-14
  • CHR

    CHR - 2020-12-10

    Given this code

    template<long Len = 128, long BlockSize = 128, class T = wchar_t>
    class String {
    public:
      bool Format(const wchar_t FormatStr[], ...) { return true; }
    };
    
    void FTest() {
      double d{};
    
      String s;
      s.Format(L"%i", d); // only one warning here
    
      String<> s2;
      s2.Format(L"%i", d);
    
      String<5, 5> s3;
      s3.Format(L"%i", d);
    }
    

    and this library configuration

    <?xml version="1.0"?>
    <def>
      <function name="String::Format">
        <noreturn>false</noreturn>
        <leak-ignore/>
        <formatstr type="printf"/>
        <arg nr="1">
          <formatstr/>
        </arg>
      </function>
      </def>
    

    Is there a way to get warnings for all three calls to Format()?

     
  • Daniel Marjamäki

    As far as I know, I do not think you can do it right now. I agree that would be a good feature.

     
  • CHR

    CHR - 2020-12-14

    That's what I thought... Thanks for the reply!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.