This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | hfuru |
|---|---|
| Recipients | hfuru |
| Date | 2008年05月19日.21:29:19 |
| SpamBayes Score | 0.0001427643 |
| Marked as misclassified | No |
| Message-id | <1211232563.03.0.480695098403.issue2921@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
It can be cumbersome to embed Python in a program which also #includes
a config.h from autoconf, because Python's and the program's autoconf
macros may interfere with each other. Assuming it compiles at all,
both could define the same features, sometimes the same way and
sometimes differently. Or one could be compiled with a feature macro
undefined and another with it defined, resulting in binary
incompatibility with the library which was compiled with the macro
undefined.
So one has to do something like: put the Python calls in one set of
files, the calls to the embedding program in another set, and make
them communicate via some glue code.
For this reason, please do not declare/#define symbols other than
those starting with 'py' in the include files that an embedded program
needs. Thus, do not #include at least pyconfig.h, pymath.h and
pyport.h as they are today.
Or to keep backwards compatibility, wrap such definitions in
#ifndef PYTHON_NAMESPACE_ONLY
which an application can #define before #including Python files.
Instead, you can #define/declare symbols that match the current
autoconf symbols but are prefixed with PY_, and make use of those in
#ifdefs in the include files. The files defining this can hopefully
be autogenerated, e.g. generate a .c file like
#include "pyconfig.h"
int main() {
#ifdef HAVE_WHATEVER
puts("PY_HAVE_WHATEVER");
#endif
...
}
Things like acosh() from pymath.h which you define if the system lacks
it, could become something like this:
#include <math.h> /* get acosh etc */
...
extern double py_acosh(double); /* always present in python */
#if !defined(PYTHON_NAMESPACE_ONLY) && !defined(HAVE_ACOSH)
/* an other package's autoconf might do the same, so hide this
* if requested */
extern double acosh(double);
#endif
#if !defined(PYTHON_NAMESPACE_ONLY) || defined(HAVE_ACOSH)
#define py_acosh acosh /* optimization - hide wrapper function */
#endif |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008年05月19日 21:29:23 | hfuru | set | spambayes_score: 0.000142764 -> 0.0001427643 recipients: + hfuru |
| 2008年05月19日 21:29:23 | hfuru | set | spambayes_score: 0.000142764 -> 0.000142764 messageid: <1211232563.03.0.480695098403.issue2921@psf.upfronthosting.co.za> |
| 2008年05月19日 21:29:22 | hfuru | link | issue2921 messages |
| 2008年05月19日 21:29:19 | hfuru | create | |