[Lldb-commits] fixing build warnings on Linux

Kopec, Matt matt.kopec at intel.com
Wed Nov 28 12:58:58 PST 2012


Hi all,

On Linux, there are hundreds of build warnings and I've taken steps to resolve them. Our goal is to be able to build trunk with -Werror.  Some warnings appear so often a patch would be painful to review. For these cases, I'll start with a category of warnings and a general solution on how to resolve for all instances.

Printf format placeholder warnings:

/home/mkopec1/dev/llvm/tools/lldb/source/API/SBBreakpoint.cpp:482:97: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
        log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %llu", m_opaque_sp.get(), (uint64_t)num_resolved);
                                                                                                                         ~~~                                     ^~~~~~~~~~~~~~~
                                                                                                                          %lu

On Mac OS X, uint64_t is unsigned long long but on Linux (and FreeBSD) may be unsigned long or unsigned long long. Using the macros in inttypes.h will use the correct format placeholder.


-         log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %llu", m_opaque_sp.get(), (uint64_t)num_resolved);
+        log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64, m_opaque_sp.get(), (uint64_t)num_resolved);

Does this seem reasonable?

Thanks,
Matt




More information about the lldb-commits mailing list