Thread: error when compiling a c function

error when compiling a c function

From
Ioana Danes
Date:
Hello,

I built a c function that exports data from various tables into a text file but when I compile the function I get this
error:

In file included from /usr/include/pgsql/server/postgres.h:48,
                 from myfile.c:1:
/usr/include/pgsql/server/utils/elog.h:69:28: error: utils/errcodes.h: No such file or directory

If I remove the utils/ folder in front of the errcodes.h file in elog.h then it works.

The only think I don't like (but I can live with...) is that every time I install a new version of postgres I have to
edit/usr/include/pgsql/server/utils/elog.h file and change the line: 
#include "utils/errcodes.h"
into
#include "errcodes.h"

Is there possible to get this fixed in the future release? I am using Suse compiled versions of Postgres.

Here is the "very" simplified version of my function:

#include "/usr/include/pgsql/server/postgres.h"
#include "/usr/include/pgsql/server/fmgr.h"

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif


PG_FUNCTION_INFO_V1(initializefile);

Datum
initializefile(PG_FUNCTION_ARGS)
{
    PG_RETURN_INT32(1);
}


Thank you,
Ioana

Re: error when compiling a c function

From
Sebastian Jaenicke
Date:
On Wed, Jul 27, 2011 at 09:34:20AM -0700, Ioana Danes wrote:
[..]
> #include "/usr/include/pgsql/server/postgres.h"
> #include "/usr/include/pgsql/server/fmgr.h"

#include "postgres.h"
#include "fmgr.h"

> #ifdef PG_MODULE_MAGIC

#ifndef

> PG_MODULE_MAGIC;
> #endif

...and compile with -I`pg_config --includedir-server`.

- Sebastian

--
A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Attachment

Re: error when compiling a c function

From
Ioana Danes
Date:
Thanks a lot Sebastian

--- On Wed, 7/27/11, Sebastian Jaenicke <sjaenick@CeBiTec.Uni-Bielefeld.DE> wrote:

> From: Sebastian Jaenicke <sjaenick@CeBiTec.Uni-Bielefeld.DE>
> Subject: Re: [GENERAL] error when compiling a c function
> To: "Ioana Danes" <ioanasoftware@yahoo.ca>
> Cc: "PostgreSQL General" <pgsql-general@postgresql.org>
> Received: Wednesday, July 27, 2011, 2:12 PM
> On Wed, Jul 27, 2011 at 09:34:20AM
> -0700, Ioana Danes wrote:
> [..]
> > #include "/usr/include/pgsql/server/postgres.h"
> > #include "/usr/include/pgsql/server/fmgr.h"
>
> #include "postgres.h"
> #include "fmgr.h"
>
> > #ifdef PG_MODULE_MAGIC
>
> #ifndef
>
> > PG_MODULE_MAGIC;
> > #endif
>
> ...and compile with -I`pg_config --includedir-server`.
>
> - Sebastian
>
> --
> A: Maybe because some people are too annoyed by
> top-posting.
> Q: Why do I not get an answer to my question(s)?
> A: Because it messes up the order in which people normally
> read text.
> Q: Why is top-posting such a bad thing?
>

Re: error when compiling a c function

From
Rob Sargent
Date:

On 07/27/2011 12:38 PM, Ioana Danes wrote:
> Thanks a lot Sebastian
>
> --- On Wed, 7/27/11, Sebastian Jaenicke <sjaenick@CeBiTec.Uni-Bielefeld.DE> wrote:
>
>> From: Sebastian Jaenicke <sjaenick@CeBiTec.Uni-Bielefeld.DE>
>> Subject: Re: [GENERAL] error when compiling a c function
>> To: "Ioana Danes" <ioanasoftware@yahoo.ca>
>> Cc: "PostgreSQL General" <pgsql-general@postgresql.org>
>> Received: Wednesday, July 27, 2011, 2:12 PM
>> On Wed, Jul 27, 2011 at 09:34:20AM
>> -0700, Ioana Danes wrote:
>> [..]
>>> #include "/usr/include/pgsql/server/postgres.h"
>>> #include "/usr/include/pgsql/server/fmgr.h"
>> #include "postgres.h"
>> #include "fmgr.h"
>>
>>> #ifdef PG_MODULE_MAGIC
>> #ifndef
>>
>>> PG_MODULE_MAGIC;
>>> #endif
>> ...and compile with -I`pg_config --includedir-server`.
>>
>> - Sebastian
>>
>> --
>> A: Maybe because some people are too annoyed by
>> top-posting.
>> Q: Why do I not get an answer to my question(s)?
>> A: Because it messes up the order in which people normally
>> read text.
>> Q: Why is top-posting such a bad thing?
>>
Apparently the OP didn't read you .sig.  I for one prefer top-posted
threads (and though the whole everything in every message has gotten
completely out of hand).


Re: error when compiling a c function

From
Eric Ridge
Date:
On Wed, Jul 27, 2011 at 2:12 PM, Sebastian Jaenicke
<sjaenick@cebitec.uni-bielefeld.de> wrote:
> On Wed, Jul 27, 2011 at 09:34:20AM -0700, Ioana Danes wrote:
>
>> #ifdef PG_MODULE_MAGIC
>
> #ifndef

Just to avoid confusion...  #ifdef *is* correct.  See:

    http://www.postgresql.org/docs/current/static/xfunc-c.html

(I can't comment on the OP's actual problem)

eric