Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D1DC0634F61 for ; Mon, 6 Apr 2009 10:36:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 77729-03 for ; Mon, 6 Apr 2009 10:36:03 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from blu0-omc3-s33.blu0.hotmail.com (blu0-omc3-s33.blu0.hotmail.com [65.55.116.108]) by mail.postgresql.org (Postfix) with ESMTP id 190F86343E0 for ; Mon, 6 Apr 2009 10:36:03 -0300 (ADT) Received: from BLU133-W10 ([65.55.116.73]) by blu0-omc3-s33.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 6 Apr 2009 06:36:01 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_875f81fd-da8a-4d0a-8891-11613126be78_" X-Originating-IP: [131.173.79.102] From: eehab hamzeh To: Subject: Re: Date: Mon, 6 Apr 2009 13:36:01 +0000 Importance: Normal In-Reply-To: References: MIME-Version: 1.0 X-OriginalArrivalTime: 06 Apr 2009 13:36:01.0345 (UTC) FILETIME=[A021DB10:01C9B6BC] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.807 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001, SUBJ_ALL_CAPS=1.806 X-Spam-Level: * X-Archive-Number: 200904/75 X-Sequence-Number: 36569 --_875f81fd-da8a-4d0a-8891-11613126be78_ Content-Type: text/plain; charset="windows-1255" Content-Transfer-Encoding: 8bit here are the code and the error , i compile them using vc++ 6 and VC++ 2008 and minGW the example below are for minGW THANKS #include "postgres.h" #include #include "fmgr.h" #ifdef PG_MODULE_MAGIC PG_MODULE_MAGIC; #endif /* by value */ PG_FUNCTION_INFO_V1(add_one); Datum add_one(PG_FUNCTION_ARGS) { int32 arg = PG_GETARG_INT32(0); PG_RETURN_INT32(arg + 1); } /* by reference, fixed length */ PG_FUNCTION_INFO_V1(add_one_float8); Datum add_one_float8(PG_FUNCTION_ARGS) { /* The macros for FLOAT8 hide its pass-by-reference nature. */ float8 arg = PG_GETARG_FLOAT8(0); PG_RETURN_FLOAT8(arg + 1.0); } PG_FUNCTION_INFO_V1(makepoint); Datum makepoint(PG_FUNCTION_ARGS) { /* Here, the pass-by-reference nature of Point is not hidden. */ Point *pointx = PG_GETARG_POINT_P(0); Point *pointy = PG_GETARG_POINT_P(1); Point *new_point = (Point *) palloc(sizeof(Point)); new_point->x = pointx->x; new_point->y = pointy->y; PG_RETURN_POINT_P(new_point); } /* by reference, variable length */ PG_FUNCTION_INFO_V1(copytext); Datum copytext(PG_FUNCTION_ARGS) { text *t = PG_GETARG_TEXT_P(0); /* * VARSIZE is the total size of the struct in bytes. */ text *new_t = (text *) palloc(VARSIZE(t)); VARATT_SIZEP(new_t) = VARSIZE(t); /* * VARDATA is a pointer to the data region of the struct. */ memcpy((void *) VARDATA(new_t), /* destination */ (void *) VARDATA(t), /* source */ VARSIZE(t)-VARHDRSZ); /* how many bytes */ PG_RETURN_TEXT_P(new_t); } PG_FUNCTION_INFO_V1(concat_text); Datum concat_text(PG_FUNCTION_ARGS) { text *arg1 = PG_GETARG_TEXT_P(0); text *arg2 = PG_GETARG_TEXT_P(1); int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ; text *new_text = (text *) palloc(new_text_size); VARATT_SIZEP(new_text) = new_text_size; memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ); memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ), VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ); PG_RETURN_TEXT_P(new_text); } the error in function 'makepoint': error: 'Point' undeclared (first use in this function) error: (each undeclared identifier is reported only one error: for each function it appears in.) error: 'pointx' undeclared (first use in ´this function) error: 'pointy' undeclared (first use in his fnction) error 'new_point' undeclared (first use in his function) error: syntax error befre ')' oken in function 'copy text': error: 'invalid lvalue in assinment In function 'concat_text' error: invalid lvalue in assignement warning no new line at end of file Please any direction of how to solve the problem thanks _________________________________________________________________ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ --_875f81fd-da8a-4d0a-8891-11613126be78_ Content-Type: text/html; charset="windows-1255" Content-Transfer-Encoding: 8bit
here are the code and the error , i compile them using vc++ 6 and VC++ 2008 and minGW the example below are for minGW
THANKS

#include "postgres.h"
#include <string.h>
#include "fmgr.h"

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

/* by value */

PG_FUNCTION_INFO_V1(add_one);
         
Datum
add_one(PG_FUNCTION_ARGS)
{
    int32   arg = PG_GETARG_INT32(0);

    PG_RETURN_INT32(arg + 1);
}

/* by reference, fixed length */

PG_FUNCTION_INFO_V1(add_one_float8);

Datum
add_one_float8(PG_FUNCTION_ARGS)
{
&nb sp;   /* The macros for FLOAT8 hide its pass-by-reference nature. */
    float8   arg = PG_GETARG_FLOAT8(0);

    PG_RETURN_FLOAT8(arg + 1.0);
}

PG_FUNCTION_INFO_V1(makepoint);

Datum
makepoint(PG_FUNCTION_ARGS)
{
    /* Here, the pass-by-reference nature of Point is not hidden. */
    Point     *pointx = PG_GETARG_POINT_P(0);
    Point     *pointy = PG_GETARG_POINT_P(1);
    Point     *new_point = (Point *) palloc(sizeof(Point));

    new_point->x = pointx->x;
    new_point->y = pointy->y;
       
    PG_RETURN_POINT_P(new_point);
}

/* by reference, variable length */

PG_FUNCTION_INFO_V1(copytext);

Datum
copytext(PG_FUNCTION_ARGS)
{
    text     *t = PG_GETARG_TEXT_P(0);
    /*
     * VARSIZE is the total size of the struct in bytes.
     */
    text     *new_t = (text *) palloc(VARSIZE(t));
    VARATT_SIZEP(new_t) = VARSIZE(t);
    /*
     * VARDATA is a pointer to the data region of the struct.
     */
    memcpy((void *) VARDATA(new_t), /* destination */
           (void *) VARDATA(t),     /* source */
           VARSIZE(t)-VARHDRSZ);    /* how many bytes */
    PG_RETURN_TEXT_P(new_t);
}

PG_FUNCTION_INFO_V1(concat_text);

Datum
concat_text(PG_FUNCTION_ARGS)
{
    text  *arg1 = PG_GETARG_TEXT_P(0);
    text  *arg2 = PG_GETARG_TEXT_P(1);
    int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;
    text *new_text = (text *) palloc(new_text_size);

    VARATT_SIZEP(new_text) = new_text_size;
    memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ);
    memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ),
           VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ);
  &n bsp; PG_RETURN_TEXT_P(new_text);
}


the error

in function 'makepoint':
error: 'Point' undeclared (first use in this function)
error: (each undeclared identifier is reported only one
error: for each function it appears in.)
error: 'pointx' undeclared (first use in ´this function)
error: 'pointy' undeclared (first use in his fnction)
error 'new_point' undeclared (first use in his function)
error: syntax error befre ')' oken
in function 'copy text':
error: 'invalid lvalue in assinment
In function 'concat_text'
error: invalid lvalue in assignement
warning no new line at end of file

Please any direction of how to solve the problem

thanks

< img alt="">




check out the rest of the Windows Live™. More than mail–Windows Live™ goes way beyond your inbox. More than messages --_875f81fd-da8a-4d0a-8891-11613126be78_--