[Lldb-commits] fixing build warnings on Linux
Kaylor, Andrew
andrew.kaylor at intel.com
Thu Nov 29 17:07:07 PST 2012
It looked to me like a whole lot of these were coming because ScriptInterpreterPython.h was being included somewhere deep in an include chain from places that probably didn't need Python at all. I wondered if there was a way to avoid including Python.h from ScriptInterpreter.h and only bring it in when it was needed.
-Andy
-----Original Message-----
From: lldb-commits-bounces at cs.uiuc.edu [mailto:lldb-commits-bounces at cs.uiuc.edu] On Behalf Of Kopec, Matt
Sent: Thursday, November 29, 2012 2:05 PM
To: lldb-commits at cs.uiuc.edu
Subject: Re: [Lldb-commits] fixing build warnings on Linux
Moving on, another warning popping up many times:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/lldb.cpp:13:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/Debugger.h:26:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatManager.h:21:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatNavigator.h:24:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatClasses.h:28:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Interpreter/ScriptInterpreterPython.h:23:
In file included from /usr/include/python2.7/Python.h:8:
/usr/include/python2.7/pyconfig.h:1158:9: warning: '_POSIX_C_SOURCE' macro redefined #define _POSIX_C_SOURCE 200112L
^
/usr/include/features.h:163:10: note: previous definition is here
# define _POSIX_C_SOURCE 200809L
^
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/lldb.cpp:13:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/Debugger.h:26:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatManager.h:21:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatNavigator.h:24:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatClasses.h:28:
In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Interpreter/ScriptInterpreterPython.h:23:
In file included from /usr/include/python2.7/Python.h:8:
/usr/include/python2.7/pyconfig.h:1180:9: warning: '_XOPEN_SOURCE' macro redefined #define _XOPEN_SOURCE 600
^
/usr/include/features.h:165:10: note: previous definition is here # define _XOPEN_SOURCE 700
>From Python documentation (http://docs.python.org/3.1/c-api/intro.html#include-files):
Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included.
I suggest adding a new header (include/lldb/lldb-python.h) and including it at the top of each source file producing this warning. The header source would look like this:
#ifndef LLDB_lldb_python_h_
#define LLDB_lldb_python_h_
// Python.h needs to be included before any system headers in order to avoid redefinition of macros
#ifdef LLDB_DISABLE_PYTHON
// Python is disabled in this build
#else
#if defined (__APPLE__)
#include <Python/Python.h>
#else
#include <Python.h>
#endif
#endif // LLDB_DISABLE_PYTHON
#endif // LLDB_lldb_python_h_
Thoughts?
________________________________________
From: lldb-commits-bounces at cs.uiuc.edu [lldb-commits-bounces at cs.uiuc.edu] on behalf of Kopec, Matt [matt.kopec at intel.com]
Sent: Thursday, November 29, 2012 3:23 PM
To: Greg Clayton
Cc: lldb-commits at cs.uiuc.edu
Subject: Re: [Lldb-commits] fixing build warnings on Linux
Yes, these do exist. Initially, I will replace the warning cases. Thanks :) ________________________________________
From: Greg Clayton [gclayton at apple.com]
Sent: Wednesday, November 28, 2012 4:32 PM
To: Kopec, Matt
Cc: lldb-commits at cs.uiuc.edu
Subject: Re: [Lldb-commits] fixing build warnings on Linux
On Nov 28, 2012, at 12:58 PM, "Kopec, Matt" <matt.kopec at intel.com> wrote:
> 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?
Yes, as long asthere are PRI macros for all formats ('i', 'u', 'x', 'o', etc).
_______________________________________________
lldb-commits mailing list
lldb-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
_______________________________________________
lldb-commits mailing list
lldb-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
More information about the lldb-commits
mailing list