'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type

From: Andrea spanu <spanu_andrea(at)yahoo(dot)it>
To: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: 'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type
Date: 2016-12-05 11:19:54
Message-ID: 1178215532.10829744.1480936794933@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'am began with a server side program on Windows with MinGW, and after linked everything I get this warning 'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type' , but worst It doesn't recognize the functions declared as extern. Among the others palloc() and pfree(), or  the macro ereport()  Or better they doesn't get linked if I call those function from the server the server crashes.
the search directories are the followings:
Compiler:
C:\Program Files (x86)\PostgreSQL\9.6\includeC:\Program Files (x86)\PostgreSQL\9.6\include\serverC:\Program Files (x86)\PostgreSQL\9.6\include\server\win32linker:C:\Program Files (x86)\PostgreSQL\9.6\libC:\Program Files (x86)\PostgreSQL\9.6\bin

I get those libraryes linked:C:\Program Files (x86)\PostgreSQL\9.6\lib\postgres.libC:\Program Files (x86)\PostgreSQL\9.6\lib\libpq.lib
It is not matter of code bacause also the tutorial example complex.c crashes.To allow me to write the remaining code, I hacked as follow:
#define palloc(a) malloc(a)
but since I cannot free it, there is the risk of memory leakage.I would ask if I missing some library or some path.

Then, but I do not know if the problems are related,
I convert the input cstring, I cannot use the macros for the varlena struct or the server also crashes:
typedef struct varlena Node;

PG_FUNCTION_INFO_V1(node_in);
Datum
node_in(PG_FUNCTION_ARGS)
{

    /*if (PG_NARGS()==0 )  //this is quoted since if call the ereport the server crashes
            ereport(ERROR,
                (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
                 errmsg("invalid input syntax for complex")));
*/
    char * s=PG_GETARG_CSTRING(0);

    int32 sz= strlen(s)+VARHDRSZ+1;
    Node *res=palloc(sz); ///this is currently replaced by malloc() through a macro

    SET_VARSIZE(res, sz-VARHDRSZ-1);
    strcpy(VARDATA(res),s);

    if (validate(res)==0)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
                 errmsg("invalid input syntax for complex")));

    PG_RETURN_TEXT_P(res);
}

But for the output function, if I use PG_GETARG_TEXT_P(0),the server also crashesCurrently I hacked as follow, all the quoted rows are the firsts attemps:
Datum
node_out(PG_FUNCTION_ARGS)
{
    Node* txt = PG_GETARG_CSTRING(0);
    /*char * targ=palloc(VARSIZE(res)-VARHDRSZ+1);
    strcpy(targ,VARDATA(res));*/
    PG_RETURN_CSTRING(txt->vl_dat);
}

Some Ideas?

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2016-12-05 18:24:09 Re: 'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type
Previous Message ndaley . 2016-12-01 17:21:31 Re: Monitoring Parallel Queries