Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMPILER macro redefinition in _compiler.c #9444

Open
pllim opened this issue Oct 23, 2019 · 3 comments
Open

COMPILER macro redefinition in _compiler.c #9444

pllim opened this issue Oct 23, 2019 · 3 comments

Comments

@pllim
Copy link
Member

pllim commented Oct 23, 2019

Description

When doing development work on Windows, I see a warning about 'COMPILER': macro redefinition when I build astropy from source. Probably harmless?

Expected behavior

No redefinition of COMPILER macro in C.

Actual behavior

Searching for cython>=0.29.13
Best match: cython 0.29.13
Processing cython-0.29.13-py3.7-win-amd64.egg

Using ...\astropy\.eggs\cython-0.29.13-py3.7-win-amd64.egg
running test
installing to temporary directory: ...
_compiler.c
astropy\_compiler.c(58): warning C4005: 'COMPILER': macro redefinition
c:\...\envs\py37\include\pyconfig.h(126): note: see previous definition of 'COMPILER'
   Creating library ...\astropy\compiler_version.cp37-win_amd64.lib and
   object ...\astropy\compiler_version.cp37-win_amd64.exp
Generating code
Finished generating code
_compiler.c
#include <Python.h>

/***************************************************************************
 * Macros for determining the compiler version.
 *
 * These are borrowed from boost, and majorly abridged to include only
 * the compilers we care about.
 ***************************************************************************/

#define STRINGIZE(X) DO_STRINGIZE(X)
#define DO_STRINGIZE(X) #X

#if defined __clang__
/*  Clang C++ emulates GCC, so it has to appear early. */
#    define COMPILER "Clang version " __clang_version__

#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
/* Intel */
#    if defined(__INTEL_COMPILER)
#        define INTEL_VERSION __INTEL_COMPILER
#    elif defined(__ICL)
#        define INTEL_VERSION __ICL
#    elif defined(__ICC)
#        define INTEL_VERSION __ICC
#    elif defined(__ECC)
#        define INTEL_VERSION __ECC
#    endif
#    define COMPILER "Intel C compiler version " STRINGIZE(INTEL_VERSION)

#elif defined(__GNUC__)
/* gcc */
#    define COMPILER "GCC version " __VERSION__

#elif defined(__SUNPRO_CC)
/* Sun Workshop Compiler */
#    define COMPILER "Sun compiler version " STRINGIZE(__SUNPRO_CC)

#elif defined(_MSC_VER)
/* Microsoft Visual C/C++
   Must be last since other compilers define _MSC_VER for compatibility as well */
#    if _MSC_VER < 1200
#        define COMPILER_VERSION 5.0
#    elif _MSC_VER < 1300
#        define COMPILER_VERSION 6.0
#    elif _MSC_VER == 1300
#        define COMPILER_VERSION 7.0
#    elif _MSC_VER == 1310
#        define COMPILER_VERSION 7.1
#    elif _MSC_VER == 1400
#        define COMPILER_VERSION 8.0
#    elif _MSC_VER == 1500
#        define COMPILER_VERSION 9.0
#    elif _MSC_VER == 1600
#        define COMPILER_VERSION 10.0
#    else
#        define COMPILER_VERSION _MSC_VER
#    endif
#    define COMPILER "Microsoft Visual C++ version " STRINGIZE(COMPILER_VERSION)

#else
/* Fallback */
#    define COMPILER "Unknown compiler"

#endif


/***************************************************************************
 * Module-level
 ***************************************************************************/

struct module_state {
/* The Sun compiler can't handle empty structs */
#if defined(__SUNPRO_C) || defined(_MSC_VER)
    int _dummy;
#endif
};

static struct PyModuleDef moduledef = {
    PyModuleDef_HEAD_INIT,
    "compiler_version",
    NULL,
    sizeof(struct module_state),
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
};

#define INITERROR return NULL

PyMODINIT_FUNC
PyInit_compiler_version(void)


{
  PyObject* m;

  m = PyModule_Create(&moduledef);

  if (m == NULL)
    INITERROR;

  PyModule_AddStringConstant(m, "compiler", COMPILER);

  return m;
}

System Details

Windows-10-10.0.18362-SP0
Python 3.7.1 | packaged by conda-forge | (default, Nov 13 2018, 19:01:41) [MSC v.1900 64 bit (AMD64)]
Numpy 1.16.3
Scipy 1.1.0
astropy 4.0.dev26224

@MSeifert04
Copy link
Contributor

I've also seen this before. Do you happen to know the definition before (python) and after (ours)?

@bsipocz
Copy link
Member

bsipocz commented Oct 23, 2019

(off topic, but I totally forgot about this label of ours :) )

@pllim
Copy link
Member Author

pllim commented Oct 23, 2019

@MSeifert04 , "ours" is the one defined in _compiler.c above. Here is the one from pyconfig.h:

/* set the COMPILER */
#ifdef MS_WIN64
#if defined(_M_X64) || defined(_M_AMD64)
#if defined(__INTEL_COMPILER)
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
#else
#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
#endif /* __INTEL_COMPILER */
#define PYD_PLATFORM_TAG "win_amd64"
#else
#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
#endif
#endif /* MS_WIN64 */

And it is provided by CPython manually at https://github.com/python/cpython/blob/master/PC/pyconfig.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants