Title: pyconfig.h macro "timezone" name clashes with user source are likely
Type: enhancement Stage: resolved
Components: Windows Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.5
Status: closed Resolution: duplicate
Dependencies: Superseder: VS 2015 pyconfig.h #define timezone _timezone conflicts with timeb.h
View: 24643
Assigned To: Nosy List: bwanamarko, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2018-09-13 06:10 by bwanamarko, last changed 2018-09-13 14:40 by zach.ware. This issue is now closed.

Messages (2)
msg325235 - (view) Author: Mark Mikofski (bwanamarko) Date: 2018-09-13 06:10
TL;DR: if PC user compiles source which defines "timezone" in a header, and includes Python.h after the header, then the macro also called "timezone" in pyconfig.h will redefine the users source, yielding unexpected results.

see Cython google group for an actual use case where this occurred:!topic/cython-users/pjbhYrpl_rU

trying to compile NREL SPA code which has a header file with a struct with a timezone field fails with the following traceback:
spa.h(88): error C2032: '__timezone': function cannot be member of struct '<anonymous-tag>'

here's the macro in PC/pyconfig.h in master as of 5489bdad

/* VS 2015 defines these names with a leading underscore */
#if _MSC_VER >= 1900
#define timezone _timezone
#define daylight _daylight
#define tzname _tzname
msg325249 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2018-09-13 14:40
This is a duplicate of bpo-24643.
Date User Action Args
2018-09-13 14:40:35zach.waresetstatus: open -> closed
superseder: VS 2015 pyconfig.h #define timezone _timezone conflicts with timeb.h
messages: + msg325249

resolution: duplicate
stage: resolved
2018-09-13 14:35:13ned.deilysetnosy: + tim.golden, steve.dower, zach.ware, paul.moore
components: + Windows, - Build
2018-09-13 06:10:52bwanamarkocreate