annotate PC/example_nt/example.c @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents a5298f371be7
children bd0e361bd642
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4223
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #include "Python.h"
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 static PyObject *
13660
a1ce07218781 Miscelaneous ANSIfications. I'm assuming here 'main' should take (int,
Thomas Wouters <thomas@python.org>
parents: 4223
diff changeset
4 ex_foo(PyObject *self, PyObject *args)
4223
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 {
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 printf("Hello, world\n");
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 Py_INCREF(Py_None);
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 return Py_None;
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 }
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 static PyMethodDef example_methods[] = {
38490
a5298f371be7 Convert more modules to METH_VARARGS.
Georg Brandl <georg@python.org>
parents: 37923
diff changeset
12 {"foo", ex_foo, METH_VARARGS, "foo() doc string"},
4223
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 {NULL, NULL}
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 };
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
37923
834fd9b3ceee Port to Python 2.5. Drop .DEF file. Change output file names to .pyd.
Martin v. Löwis <martin@v.loewis.de>
parents: 13660
diff changeset
16 PyMODINIT_FUNC
13660
a1ce07218781 Miscelaneous ANSIfications. I'm assuming here 'main' should take (int,
Thomas Wouters <thomas@python.org>
parents: 4223
diff changeset
17 initexample(void)
4223
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 {
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 Py_InitModule("example", example_methods);
180c1d3dac41 A directory with a working example of how to build an extension.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 }