Patchwork [1,of,2] setup: enable pedantic warning of gcc to catch MSVC compatibility issue

login
register
mail settings
Submitter Yuya Nishihara
Date April 18, 2013, 4:39 p.m.
Message ID <d81cbdba4275b4bbba56.1366303150@gimlet>
Download mbox | patch
Permalink /patch/1424/
State Deferred, archived
Headers show

Comments

Yuya Nishihara - April 18, 2013, 4:39 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1366302847 -32400
#      Fri Apr 19 01:34:07 2013 +0900
# Node ID d81cbdba4275b4bbba564993c2918378ea9d7388
# Parent  7d31f2e42a8afb54c8fae87e8e3e29a63578aea4
setup: enable pedantic warning of gcc to catch MSVC compatibility issue

MSVC is strict for the mixed declaration and code, which is invalid in C89.

CFLAGS has no effect except for Unix-like environment. But I'm a bit afraid
this change might have a platform-specific issue. I've tested with gcc and
clang (Linux amd64) and MSVC.
Matt Mackall - April 22, 2013, 8:16 p.m.
On Fri, 2013-04-19 at 01:39 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1366302847 -32400
> #      Fri Apr 19 01:34:07 2013 +0900
> # Node ID d81cbdba4275b4bbba564993c2918378ea9d7388
> # Parent  7d31f2e42a8afb54c8fae87e8e3e29a63578aea4
> setup: enable pedantic warning of gcc to catch MSVC compatibility issue
> 
> MSVC is strict for the mixed declaration and code, which is invalid in C89.
> 
> CFLAGS has no effect except for Unix-like environment. But I'm a bit afraid
> this change might have a platform-specific issue. I've tested with gcc and
> clang (Linux amd64) and MSVC.

Pretty sure we've got some non-gcc-like Unix compilers out there, for
instance on AIX.
Yuya Nishihara - April 23, 2013, 4:27 p.m.
On Mon, 22 Apr 2013 15:16:49 -0500, Matt Mackall wrote:
> On Fri, 2013-04-19 at 01:39 +0900, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1366302847 -32400
> > #      Fri Apr 19 01:34:07 2013 +0900
> > # Node ID d81cbdba4275b4bbba564993c2918378ea9d7388
> > # Parent  7d31f2e42a8afb54c8fae87e8e3e29a63578aea4
> > setup: enable pedantic warning of gcc to catch MSVC compatibility issue
> > 
> > MSVC is strict for the mixed declaration and code, which is invalid in C89.
> > 
> > CFLAGS has no effect except for Unix-like environment. But I'm a bit afraid
> > this change might have a platform-specific issue. I've tested with gcc and
> > clang (Linux amd64) and MSVC.
> 
> Pretty sure we've got some non-gcc-like Unix compilers out there, for
> instance on AIX.

Ah, thanks.

It seems there's no quick way to specify compiler-dependent flags in distutils,
so I'll set CFLAGS manually:

    % make local CFLAGS='-pedantic -Wno-long-long'

Regards,

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -520,6 +520,10 @@  if sys.platform == 'darwin' and os.path.
     if xcode4:
         os.environ['ARCHFLAGS'] = ''
 
+if 'CFLAGS' not in os.environ:
+    # warn mixed declaration and code which is invalid and unsupported by MSVC
+    os.environ['CFLAGS'] = '-pedantic -Wno-long-long'
+
 setup(name='mercurial',
       version=setupversion,
       author='Matt Mackall and many others',