[Pyrex] #if
Francesc Alted
falted at openlc.org
Fri Oct 17 19:50:45 CEST 2003
A Divendres 17 Octubre 2003 19:32, Francesc Alted va escriure:
>
> cdef int ucl_version
> cdef extern from "myucl.h":
> int register_ucl()
>
> # Initialize & register ucl
> ucl_version = register_ucl()
>
> then, in the myucl.c, you have the next definition of register_ucl:
>
> #ifdef _windows
> # include "ucl/ucl.h"
> #endif
>
> int register_ucl(void) {
> #ifdef _windows
> /* Init the ucl library */
> if (ucl_init()!=UCL_E_OK)
> printf("Problems initializing UCL library\n");
> return UCL_VERSION; /* lib is available */
> #else
> return 0; /* lib is not available */
> #endif /* _windows */
Ooops!, I forgot to mention that you need to conveniently wrap the ucl
routines depending if you are in windows or not:
size_t ucl_deflate(unsigned int flags, size_t cd_nelmts,
const unsigned int cd_values[], size_t nbytes,
size_t *buf_size, void **buf)
{
size_t ret_value = 0;
#ifdef HAVE_UCL_LIB #defined in ucl/ucl.h
int status;
size_t nalloc = *buf_size;
ucl_uint out_len = (ucl_uint) nalloc;
/* Make the calls to ucl library here */
...
#endif /* HAVE_UCL_LIB */
return ret_value; /* dummy function in case you are not on windows */
}
so as to the linker won't complain.
Cheers,
--
Francesc Alted
More information about the Pyrex
mailing list