| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -35,6 +35,12 @@ | |
| #define Py_EXPORTED_SYMBOL | ||
| #define Py_LOCAL_SYMBOL | ||
| #endif | ||
| /* module init functions outside the core must be exported */ | ||
| #if defined(Py_BUILD_CORE) | ||
| #define _PyINIT_EXPORTED_SYMBOL Py_EXPORTED_SYMBOL | ||
| #else | ||
| #define _PyINIT_EXPORTED_SYMBOL __declspec(dllexport) | ||
| #endif | ||
| #else | ||
| /* | ||
| * If we only ever used gcc >= 5, we could use __has_attribute(visibility) | ||
| Expand All | @@ -52,19 +58,16 @@ | |
| #define Py_EXPORTED_SYMBOL | ||
| #define Py_LOCAL_SYMBOL | ||
| #endif | ||
| #define _PyINIT_EXPORTED_SYMBOL Py_EXPORTED_SYMBOL | ||
| #endif | ||
|
|
||
| /* only get special linkage if built as shared or platform is Cygwin */ | ||
| #if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) | ||
| # if defined(HAVE_DECLSPEC_DLL) | ||
| # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) | ||
| # define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE | ||
| # define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE | ||
| /* module init functions inside the core need no external linkage */ | ||
| /* except for Cygwin to handle embedding */ | ||
| # if defined(__CYGWIN__) | ||
| # define _PyINIT_FUNC_DECLSPEC Py_EXPORTED_SYMBOL | ||
| # else /* __CYGWIN__ */ | ||
| # if !defined(__CYGWIN__) | ||
| # define _PyINIT_FUNC_DECLSPEC | ||
| # endif /* __CYGWIN__ */ | ||
| # else /* Py_BUILD_CORE */ | ||
| Expand All | @@ -77,12 +80,6 @@ | |
| # define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE | ||
| # endif /* !__CYGWIN__ */ | ||
| # define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE | ||
| /* module init functions outside the core must be exported */ | ||
| # if defined(__cplusplus) | ||
| # define _PyINIT_FUNC_DECLSPEC extern "C" Py_EXPORTED_SYMBOL | ||
| # else /* __cplusplus */ | ||
| # define _PyINIT_FUNC_DECLSPEC Py_EXPORTED_SYMBOL | ||
| # endif /* __cplusplus */ | ||
| # endif /* Py_BUILD_CORE */ | ||
| # endif /* HAVE_DECLSPEC_DLL */ | ||
| #endif /* Py_ENABLE_SHARED */ | ||
| Expand All | @@ -96,13 +93,17 @@ | |
| #endif | ||
| #ifndef _PyINIT_FUNC_DECLSPEC | ||
| # if defined(__cplusplus) | ||
| # define _PyINIT_FUNC_DECLSPEC extern "C" Py_EXPORTED_SYMBOL | ||
| # define _PyINIT_FUNC_DECLSPEC extern "C" _PyINIT_EXPORTED_SYMBOL | ||
| # else /* __cplusplus */ | ||
| # define _PyINIT_FUNC_DECLSPEC Py_EXPORTED_SYMBOL | ||
| # define _PyINIT_FUNC_DECLSPEC _PyINIT_EXPORTED_SYMBOL | ||
| # endif /* __cplusplus */ | ||
| #endif | ||
|
|
||
| #define PyMODINIT_FUNC _PyINIT_FUNC_DECLSPEC PyObject* | ||
| #define PyMODEXPORT_FUNC _PyINIT_FUNC_DECLSPEC PyModuleDef_Slot* | ||
| #ifndef PyMODINIT_FUNC | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySupporting an already defined PyMODINIT_FUNC/PyMODEXPORT_FUNC is a new feature. Is it really worth it? I'm not against it, just curious.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt's an escape hatch: if there's an unexpected problem with this PR, this can allow people to hotfix it without patching or waiting for a new release.
Sorry, something went wrong.
All reactions
|
||
| #define PyMODINIT_FUNC _PyINIT_FUNC_DECLSPEC PyObject* | ||
| #endif | ||
| #ifndef PyMODEXPORT_FUNC | ||
| #define PyMODEXPORT_FUNC _PyINIT_FUNC_DECLSPEC PyModuleDef_Slot* | ||
| #endif | ||
|
|
||
| #endif /* Py_EXPORTS_H */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| :c:macro:`PyMODINIT_FUNC` (and the new :c:macro:`PyMODEXPORT_FUNC`) now adds | ||
| a linkage declaration (``__declspec(dllexport)``) on Windows. |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think a better option instead is to define Py_EXPORTED_SYMBOL here and then use that.
Also I feel like an escape hatch like Py_EMBED_MODULE where it basically uses Py_LOCAL_SYMBOL instead could be an option as well for when one does not want the module init function exported due to intending to use PyImport_AppendInitTab within the exe that they directly build the module into.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI don't want to change the meaning of Py_EXPORTED_SYMBOL.
For the inittab, you can avoid PyMODINIT_FUNC/PyMODEXPORT_FUNC, and just use a normal declaration.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.