Re: error C2011 in Visual Studio 2012

From: Craig Ringer <craig(at)2ndQuadrant(dot)com>
To: "Anderson C(dot) Carniel" <accarniel(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: error C2011 in Visual Studio 2012
Date: 2013-01-28 23:57:41
Message-ID: 51071075.5070104@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01/27/2013 01:14 AM, Anderson C. Carniel wrote:
> Hi,
>
> I'm trying to build a. dll file to extend the postgres server with C
> functions. I'm using visual studio 2012 to build the dll, and
> PostgreSQL 9.2. I imported all directories postgres "\include\server*"
> But I'm having the errors:
>
> error C2011: 'timezone': 'struct' type redefinition
>
> error C2011: 'itimerval': 'struct' type redefinition
>
> In the file *pg_confi_os.h* at line 205 and 214
>

First, you'll want to build with Visual Studio 2010 or older. The
Express edition works fine.

Second, it's very unlikely that you can just compile the extension .c
file stand-alone. You'll need to set a bunch of preprocesor definitions,
some of which are somewhat configuration/environment specific.

The best way to compile extensions at the moment may be to get the
PostgreSQL source tree, add your extension as a folder inside the
contrib/ directory with a Makefile, then use the tooling in
src/tools/msvc to compile the source tree including the extension.

I would really like to see this improve, with a working PGXS alternative
for Windows MSVC builds. I'm not presently aware of anything, but I
haven't investigated building extensions out of tree under Windows/MSVC
in detail yet.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2013-01-29 00:07:13 pgsql: Fast promote mode skips checkpoint at end of recovery.
Previous Message Dimitri Fontaine 2013-01-28 23:19:07 Re: Event Triggers: adding information