Enabling precompiled headers leads to warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all;

I'm using GCC 8.1.0 on my GNU/Linux system to build C++.

I'm introducing precompiled header support into my builds and it's
going fine but I did discover one issue.  I'm using the fmt library (
https://github.com/fmtlib/fmt --note I'm using the latest _released_
version 5.3.0 not the git master HEAD) and one feature of this library
is the ability to get compile-time errors for incorrect formatting
strings, using a macro around the format string.  I don't want to get
into the guts of the implementation (and certainly don't understand it
fully) but the macro looks like this:

  #define FMT_STRING(s) [] { \
    typedef typename std::remove_cv<std::remove_pointer< \
      typename std::decay<decltype(s)>::type>::type>::type ct; \
    struct str : fmt::compile_string { \
      typedef ct char_type;             \
      FMT_CONSTEXPR operator fmt::basic_string_view<ct>() const { \
        return {s, sizeof(s) / sizeof(ct) - 1}; \
      } \
    }; \
    return str{}; \
  }()

If I build my code normally without precompiled headers, all is well. 
But if I build my code WITH precompiled headers, I get this warning:

  /Foo.cpp: In lambda function:
  /src/fmt/include/fmt/format.h:3517:18: error: typedef
'Foo::myMethod()::<lambda()>::str::char_type' locally defined but not
used [-Werror=unused-local-typedefs]
         typedef ct char_type;             \

I can do something like add __attribute__((unused)) here but the thing
that I'm wondering about is why I get the warning only for precompiled
headers, but not if I don't use them?  Is that a bug in GCC's
precompiled headers?  Or an unavoidable side-effect?  Or...?




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux