style: Force Python.h to be included before main header

Python's header files set various compiler macros (e.g.,
_XOPEN_SOURCE) unconditionally. This triggers preprocessor warnings
that end up being treated as errors. The Python integration manual [1]
strongly recommends that Python.h is included before any system
header. The style guide used to mandate that Python.h is included
first in any file that needs it. This requirement was changed to
always include a source file's main header first, which ended up
triggering these errors.

This change updates the style checker to always include Python.h
before the main header file.

[1] https://docs.python.org/2/extending/extending.html

Change-Id: Id6a4f7fc64a336a8fd26691a0ca682abeb1d1579
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Pierre-Yves Péneau <pierre-yves.peneau@lirmm.fr>
This commit is contained in:
Andreas Sandberg 2017-02-07 15:28:33 +00:00
parent 227bdde922
commit 653b4657e6
4 changed files with 7 additions and 7 deletions

View file

@ -28,10 +28,10 @@
* Authors: Nathan Binkert
*/
#include "python/swig/pyevent.hh"
#include <Python.h>
#include "python/swig/pyevent.hh"
#include "base/misc.hh"
#include "sim/async.hh"
#include "sim/eventq.hh"

View file

@ -41,10 +41,10 @@
* Authors: Nathan Binkert
*/
#include "sim/init.hh"
#include <Python.h>
#include "sim/init.hh"
#include <marshal.h>
#include <zlib.h>

View file

@ -29,10 +29,10 @@
* Steve Reinhardt
*/
#include "sim/py_interact.hh"
#include <Python.h>
#include "sim/py_interact.hh"
void
py_interact()
{

View file

@ -169,8 +169,8 @@ class SortIncludes(object):
)
block_order = (
('main', ),
('python', ),
('main', ),
('c', ),
('stl', ),
('cc', ),