Skip to content

Commit c612fd4

Browse files
authored
PC/pyconfig.h: Improve readability of implicit .lib linking (GH-155995)
1 parent 95e32ba commit c612fd4

1 file changed

Lines changed: 27 additions & 33 deletions

File tree

PC/pyconfig.h

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -317,39 +317,33 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
317317
/* All windows compilers that use this header support __declspec */
318318
#define HAVE_DECLSPEC_DLL
319319

320-
/* For an MSVC DLL, we can nominate the .lib files used by extensions */
321-
#ifdef MS_COREDLL
322-
# if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
323-
/* not building the core - must be an ext */
324-
# if defined(_MSC_VER) && !defined(Py_NO_LINK_LIB)
325-
/* So MSVC users need not specify the .lib
326-
file in their Makefile */
327-
/* Define Py_NO_LINK_LIB to build extension disabling pragma
328-
based auto-linking.
329-
This is relevant when using build-system generator (e.g CMake) where
330-
the linking is explicitly handled */
331-
# if defined(Py_GIL_DISABLED)
332-
# if defined(Py_DEBUG)
333-
# pragma comment(lib,"python316t_d.lib")
334-
# elif defined(Py_LIMITED_API) || defined(Py_TARGET_ABI3T)
335-
# pragma comment(lib,"python3t.lib")
336-
# else
337-
# pragma comment(lib,"python316t.lib")
338-
# endif /* Py_DEBUG */
339-
# else /* Py_GIL_DISABLED */
340-
# if defined(Py_DEBUG)
341-
# pragma comment(lib,"python316_d.lib")
342-
# elif defined(Py_TARGET_ABI3T)
343-
# pragma comment(lib,"python3t.lib")
344-
# elif defined(Py_LIMITED_API)
345-
# pragma comment(lib,"python3.lib")
346-
# else
347-
# pragma comment(lib,"python316.lib")
348-
# endif /* Py_DEBUG */
349-
# endif /* Py_GIL_DISABLED */
350-
# endif /* _MSC_VER && !Py_NO_LINK_LIB */
351-
# endif /* Py_BUILD_CORE */
352-
#endif /* MS_COREDLL */
320+
/* Automatic linking of extension python3x.lib files for MSVC DLLs.
321+
This lets MSVC users build extensions without manually specifying .lib files.
322+
Define Py_NO_LINK_LIB to disable this behavior. */
323+
#if !defined(Py_NO_LINK_LIB) \
324+
&& defined(_MSC_VER) && defined(Py_ENABLE_SHARED) \
325+
&& !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
326+
/* not building the core - must be an ext */
327+
# if defined(Py_GIL_DISABLED)
328+
# if defined(Py_DEBUG)
329+
# pragma comment(lib,"python316t_d.lib")
330+
# elif defined(Py_LIMITED_API) || defined(Py_TARGET_ABI3T)
331+
# pragma comment(lib,"python3t.lib")
332+
# else
333+
# pragma comment(lib,"python316t.lib")
334+
# endif /* Py_DEBUG */
335+
# else
336+
# if defined(Py_DEBUG)
337+
# pragma comment(lib,"python316_d.lib")
338+
# elif defined(Py_TARGET_ABI3T)
339+
# pragma comment(lib,"python3t.lib")
340+
# elif defined(Py_LIMITED_API)
341+
# pragma comment(lib,"python3.lib")
342+
# else
343+
# pragma comment(lib,"python316.lib")
344+
# endif /* Py_DEBUG */
345+
# endif /* Py_GIL_DISABLED */
346+
#endif
353347

354348
#ifdef MS_WIN64
355349
/* maintain "win32" sys.platform for backward compatibility of Python code,

0 commit comments

Comments
 (0)