Thread: error C2011 in Visual Studio 2012

error C2011 in Visual Studio 2012

From
"Anderson C. Carniel"
Date:
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

I tried this solution but had no success.

How to solve this problem?


I posted the same question at stackoverflow (http://stackoverflow.com/questions/14538652/error-c2011-timezonestruct-type-redefinition-postgres), no answers there.


Best regards,


[]s

Re: error C2011 in Visual Studio 2012

From
Andrew Dunstan
Date:
On 01/26/2013 12:14 PM, 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:
>

In the first place, Note that VS2012 is not (yet) a supported build 
environment for Postgres. See 
<http://www.postgresql.org/docs/current/static/install-windows-full.html>

cheers

andrew



Re: error C2011 in Visual Studio 2012

From
Craig Ringer
Date:
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