[pcre-dev] pcrecpp::no_arg is not exported in Windows port o…

トップ ページ
このメッセージを削除
著者: George Shimanovich
日付:  
To: Pcre-dev
題目: [pcre-dev] pcrecpp::no_arg is not exported in Windows port of pcrecpp
Current Windows port of pcrecpp is not complete: pcrecpp::no_arg global
variable is not being exported. Windows does not offer straightforward
way for exporting namespace variables. One way to solve that is to use
free function (in the same namespace - see pcrecpp::no_arg_ref() below).
The #define for no_arg_ is added to avoid duplicate declarations of
pcrecpp::RE for Windows and UNIX platforms. I changed existing
declarations to use the new macro. See changes in pcrecpp.h and
pcrecpp.cpp below.

Apparently Windows cannot resolve pcrecpp::no_arg only when it is used
by application client DLL. That explains why link of pcrecpp_unittest
(which builds .exe file) does not have this problem.

I borrowed the above changes from earlier Windows port of pcrecpp
compatible with pcre 6.7. I used pcrecpp/pcre 6.7 successfully in
Windows application.

- George

pcrecpp.h:
...
// We convert user-passed pointers into special Arg objects
#ifdef _WIN32
// Windows build: Use of namespace variables is problematic on Windows.
Use of extern results in unresolved symbols at link time.
// Exporting global namespace variable results in multiple instances
created by each compilation unit that includes this header.
// This access functions provides a workaround. 
PCRECPP_EXP_DECL Arg& no_arg_ref(void);
#define no_arg_    no_arg_ref()
#else
extern Arg PCRECPP_EXP_DECL no_arg;
#define no_arg_    no_arg
#endif
//PCRECPP_EXP_DECL Arg no_arg;



class PCRECPP_EXP_DEFN RE {
...
  bool FullMatch(const StringPiece& text,
                 const Arg& ptr1 = no_arg_,
...


pcrecpp.cc:
...
namespace pcrecpp {
...
// Special object that stands-in for no argument
PCRECPP_EXP_DEFN Arg no_arg((void*)NULL);
#ifdef _WIN32
// Windows build: To solve problem with exporting global variable in
namespace in Windows
Arg& no_arg_ref(void)
{
    return no_arg;
}
#endif
...















******************Legal Disclaimer***************************
"This communication may contain confidential and privileged material
for the sole use of the intended recipient.  Any unauthorized review,
use or distribution by others is strictly prohibited.  If you have
received the message in error, please advise the sender by reply
email and delete the message. Thank you."
****************************************************************From ph10@??? Wed Jan 16 19:36:46 2008
Envelope-to: pcre-dev@???
Received: from ppsw-7.csi.cam.ac.uk ([131.111.8.137]:36168)
    by tahini.csx.cam.ac.uk with esmtp (Exim 4.69)
    (envelope-from <ph10@???>) id 1JFE45-0006xg-3k
    for pcre-dev@???; Wed, 16 Jan 2008 19:36:46 +0000
X-Cam-SpamDetails: Not scanned
X-Cam-AntiVirus: No virus found
X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/
Received: from demon-gw.quercite.com ([83.104.196.193]:50217
    helo?ercite.quercite.com)
    by ppsw-7.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.157]:587)
    with esmtpsa (PLAIN:ph10) (TLSv1:DHE-RSA-AES256-SHA:256)
    id 1JFE43-0002W0-Ov (Exim 4.67)
    (return-path <ph10@???>); Wed, 16 Jan 2008 19:36:43 +0000
Date: Wed, 16 Jan 2008 19:36:43 +0000 (GMT)
From: Philip Hazel <ph10@???>
To: Alan Lehotsky <ALehotsky@???>
In-Reply-To: <OF2783E512.641A31E2-ON852573D2.005A3197-852573D2.005D53DA@???>
Message-ID: <Pine.LNX.4.64.0801161932560.26350@???>
References: <OF2783E512.641A31E2-ON852573D2.005A3197-852573D2.005D53DA@???>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset?-ASCII
X-Spam-Score: -3.3 (---)
X-Spam-Status: No, score?.3 required~0 tests?L_TRUSTED?.8, AWL?.023,
    BAYES_00?.5 autolearn?m version^1.8
Cc: pcre-dev@???
Subject: Re: [pcre-dev] Building PCRE 7.5 with Visual Studio 7
X-BeenThere: pcre-dev@???
X-Mailman-Version: 2.1.7
Precedence: list
Reply-To: pcre-dev@???
List-Id: PCRE Development <pcre-dev.exim.org>
List-Unsubscribe: <http://lists.exim.org/mailman/listinfo/pcre-dev>,
    <mailto:pcre-dev-request@exim.org?subject?subscribe>
List-Archive: <http://lists.exim.org/lurker/list/pcre-dev.html>
List-Post: <mailto:pcre-dev@exim.org>
List-Help: <mailto:pcre-dev-request@exim.org?subject?lp>
List-Subscribe: <http://lists.exim.org/mailman/listinfo/pcre-dev>,
    <mailto:pcre-dev-request@exim.org?subject?bscribe>
X-List-Received-Date: Wed, 16 Jan 2008 19:36:46 -0000


On Wed, 16 Jan 2008, Alan Lehotsky wrote:

> Any chance that a 7.5 windows build or pre-built package is likely to
> surface in the next few weeks?


I'm afraid I don't use (and have never used) Windows myself. If someone
who understands Windows provides suitable patches for either the
./configure or the CMake build files, I will of course consider applying
them.

Philip

--
Philip Hazel