<div class="Section1"><p class="MsoNormal">I have PostgreSQL 8.4 installed on Windows XP, and am using Visual Studio
2005to write a C-Language function. I have the most basic hello-world type example (just the ‘add_one’ function from <a
href="http://www.postgresql.org/docs/8.4/interactive/xfunc-c.html">http://www.postgresql.org/docs/8.4/interactive/xfunc-c.html</a>)
ina DLL, set to compile to C code rather than C++, and I can do CREATE FUNCTION on it then use it successfully.
However,I had to do some questionable hacks to get it to build, so I’m guessing I’ve done something the wrong way. I’ve
notfound anything categorical in the archives here, so would very much appreciate anyone who can tell me if there’s a
keystep I’m missing that would make the hacks unnecessary. (For instance, I’ve come across a requirement in previous
versionsto replace pg_config.h with pg_config.h.win32, but that doesn’t seem to apply to current versions – maybe
somethingelse does.) I’m concerned the hacks might turn round and bite me otherwise once I’m implementing something
non-trivial.<pclass="MsoNormal"> <p class="MsoNormal">Having added C:\Program Files\PostgreSQL\8.4\include\server to
theinclude directories to pick up postgres.h and fmgr.h, the compiler complained about various missing include files,
startingwith ‘libintl.h’. Having read the post at <a
href="http://archives.postgresql.org/pgsql-general/2009-03/msg00332.php">http://archives.postgresql.org/pgsql-general/2009-03/msg00332.php</a>
Icreated an empty libint.h in an include dir, along with a bunch of other empty dummy files that were expected:
netdb.h,pwd.h, netinet/in.h and arpa/inet.h. <p class="MsoNormal"> <p class="MsoNormal">The code then compiles ok, but
gives‘inconsistent dll linkage’ on the line with PG_FUNCTION_INFO_V1 and the one with PG_MODULE_MAGIC.<p
class="MsoNormal"> <pclass="MsoNormal">So I’d like to ask:<p class="MsoNormal">* Is there some symbol I should be
defining,or something, to avoid all those dummy header files and make the corresponding Visual Studio headers get
pickedup?<p class="MsoNormal">* Is there something I should be doing to avoid the ‘inconsistent dll linkage’
warnings?<pclass="MsoNormal"> <p class="MsoNormal">(The C-Language functions are going to end up using some in-proc
Windows-onlycomponents, so I’m hoping that building them using Visual Studio will be the least painful way to get at
those.)<pclass="MsoNormal"> <p class="MsoNormal">Thanks in advance for any help<p class="MsoNormal"> <p
class="MsoNormal">Kevin.<pclass="MsoNormal"> <p class="MsoNormal"> <p class="MsoNormal"> </div>