Re: [pcre-dev] compile pcre-7.2 on MingW+XP

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: andy wang
CC: pcre-dev
Subject: Re: [pcre-dev] compile pcre-7.2 on MingW+XP
On Fri, 6 Jul 2007, andy wang wrote:

> Hi, Philip
>
> I have a question about the following macros in pcreposix.h
> After the changes,  the following two lines look like this:
> #    define PCREPOSIX_EXP_DECL extern __declspec(dllimport)
> #    define PCREPOSIX_EXP_DEFN  __declspec(dllexport)


Yes. They are wrong. It should be done the way it is done in pcre.h,
which is like this:

#ifndef PCRE_EXP_DECL
#  ifdef _WIN32
#    ifndef PCRE_STATIC
#      define PCRE_EXP_DECL extern __declspec(dllimport)
#    endif
#  endif
#endif


When an application is compiled, it includes pcre.h, PCRE_EXP_DECL is
not defined, so it is defined as dllimport, which is what you want.

When PCRE is compiled, the code for the modules includes
pcre_internal.h. This file contains:

#ifndef PCRE_EXP_DECL
#  ifdef _WIN32
#    ifdef DLL_EXPORT
#      define PCRE_EXP_DECL       extern __declspec(dllexport)
#      define PCRE_EXP_DEFN       __declspec(dllexport)
#      define PCRE_EXP_DATA_DEFN  __declspec(dllexport)
#    else
#      define PCRE_EXP_DECL       extern
#      define PCRE_EXP_DEFN
#      define PCRE_EXP_DATA_DEFN
#    endif
#
#  else
#    ifdef __cplusplus
#      define PCRE_EXP_DECL       extern "C"
#    else
#      define PCRE_EXP_DECL       extern
#    endif
#    ifndef PCRE_EXP_DEFN
#      define PCRE_EXP_DEFN       PCRE_EXP_DECL
#    endif
#    ifndef PCRE_EXP_DATA_DEFN
#      define PCRE_EXP_DATA_DEFN
#    endif
#  endif
#endif


*After this*, it includes pcre.h. So in this case, PCRE_EXP_DECL is
defined as dllexport. There is a large comment in the code of
pcre_internal.h, just before this code.

The bug is that the code in pcreposix.h should be handled in a similar
way, but currently isn't. I plan to fix it before the next release.

Philip

--
Philip Hazel, University of Cambridge Computing Service.