diff options
author | Jay Berkenbilt <ejb@ql.org> | 2023-12-16 15:46:44 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2023-12-16 16:06:34 +0100 |
commit | d7a364b882be44c93dc4a843bcca2ae63e805c2c (patch) | |
tree | 5ead7b212c27368b8411ae0db0d072bec5747e7a /examples/extend-c-api.h | |
parent | 924ebf9f6abb1b682bfde18f537c6f336fc72c82 (diff) | |
download | qpdf-d7a364b882be44c93dc4a843bcca2ae63e805c2c.tar.zst |
Allow regular C++ functions to interoperate with the C API
Diffstat (limited to 'examples/extend-c-api.h')
-rw-r--r-- | examples/extend-c-api.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/extend-c-api.h b/examples/extend-c-api.h new file mode 100644 index 00000000..3b2d12d4 --- /dev/null +++ b/examples/extend-c-api.h @@ -0,0 +1,25 @@ +#ifndef EXAMPLE_C_EXTEND_H +#define EXAMPLE_C_EXTEND_H + +/* + * This is an example of how to write C++ functions and make them usable with the qpdf C API. It + * consists of three files: + * - extend-c-api.h -- a plain C header file + * - extend-c-api.c -- a C program that calls the function + * - extend-c-api.cc -- a C++ file that implements the function + */ +#include <qpdf/qpdf-c.h> + +/* Declare your custom function to return QPDF_ERROR_CODE and take qpdf_data and anything else you + * need. Any errors are retrievable through the qpdf C APIs normal error-handling mechanism. + */ + +#ifdef __cplusplus +extern "C" { +#endif + QPDF_ERROR_CODE num_pages(qpdf_data qc, int* npages); +#ifdef __cplusplus +} +#endif + +#endif /* EXAMPLE_C_EXTEND_H */ |