'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type - Mailing list pgsql-novice

From Andrea spanu
Subject 'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type
Date
Msg-id 1178215532.10829744.1480936794933@mail.yahoo.com
Whole thread Raw
Responses Re: 'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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\include
C:\Program Files (x86)\PostgreSQL\9.6\include\server
C:\Program Files (x86)\PostgreSQL\9.6\include\server\win32
linker:
C:\Program Files (x86)\PostgreSQL\9.6\lib
C:\Program Files (x86)\PostgreSQL\9.6\bin

I get those libraryes linked:
C:\Program Files (x86)\PostgreSQL\9.6\lib\postgres.lib
C:\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 crashes
Currently 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?

pgsql-novice by date:

Previous
From: "ndaley ."
Date:
Subject: Re: Monitoring Parallel Queries
Next
From: Tom Lane
Date:
Subject: Re: 'PG_PRINTF_ATTRIBUTE' is an unrecognized format function type