- PR -

C言語からPostgresSqlを使うための設定について

1
投稿者投稿内容
ファーム中村
会議室デビュー日: 2008/02/07
投稿数: 1
お住まい・勤務地: 北海道
投稿日時: 2008-02-07 16:08
初めて投稿させて頂きます。
中村と申します。よろしくお願い致します。

C言語でPostgresで用意されているAPIを利用しコンパイルを行なうと以下のエラーが
表示されます。

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
sample.c:
致命的エラー F1003 C:\\Program Files\\PostgreSQL\\8.3\\include\\server\\pg_config_os.h
55: error 指令: "Postgres uses 32 bit time_t - add #define _USE_32BIT_TIME_T on Windows"

PostgresSqlをインストールした後の設定に漏れがあるのでしょうか。
Cプログラム内のヘッダー定義は、C標準ヘッダーの定義以外に
#include <postgres.h>
を定義しています。

Postgresは、msiファイルからセットアップを行なっています。
Postgresのインストールフォルダは以下のようになっておりましたので、
[DIR]PostgresSQL
 |--[DIR]8.3
 |  |--[DIR]include
 |  |   |--[DIR]server
 |  |   |   |--[FILE]postgres.h
 |  |   |   |--[FILE]・・・
 |  |   |
 |  |   |--[DIR]・・・
 |  |   |--[FILE]libpq-fe.h
 |  |   |--[FILE]・・・
 |  |      
 |  |--[DIR]lib
 |  |   |--[FILE]libpq.lib
 |  |   |--[FILE]・・・

Borland C++5.5側のコンフィグファイル(BCC32.CFG)に
-I"C:\\Borland\\Bcc55\\include"
-I"C:\\Program Files\\PostgreSQL\\8.3\\include"
-I"C:\\Program Files\\PostgreSQL\\8.3\\include\\server"

-L"C:\\Borland\\Bcc55\\lib"
-L"C:\\Program Files\\PostgreSQL\\8.3\\lib"

と記載しています。

以下のサイトを参考にしていましたがよく理解できませんでした。
http://www.pinkdragon.net/doc_lib/contents/ja/psgr_man/install-win32.html

環境は、
WindowsXP HomeEdtion
Postgres8.3.0
Borland C++5.5
です。

アドバイス頂けますようお願い致します。
未記入
大ベテラン
会議室デビュー日: 2006/12/15
投稿数: 157
投稿日時: 2008-02-07 17:18
関係ないかもしれないけど1/8辺りでWin.hが修正されているようだけど、そちらはどうなってますかね?

http://article.gmane.org/gmane.comp.db.postgresql.devel.patches/20592
あんとれ
ぬし
会議室デビュー日: 2004/01/14
投稿数: 556
投稿日時: 2008-02-07 18:16
該当箇所にはこんなコメントがありますね。

コード:
/*
 * Ensure that anyone building an extension is using a 32 bit time_t.
 * On Mingw/Msys, that should always be the case, but MSVC++ defaults
 * to 64 bits. We set that for our own build in the project files
 */
#if defined(WIN32_ONLY_COMPILER) && !defined(FRONTEND)
#ifndef _USE_32BIT_TIME_T
#error "Postgres uses 32 bit time_t - add #define _USE_32BIT_TIME_T on Windows"
#endif
#endif



ところで作成されているのは libpq を利用したクライアントAPではなくサーバモジュールでしょうか? libpq を利用したクライアントAPであれば include すべきは postgres.h ではなく libpq-fe.h です。

http://www.postgresql.jp/document/pg830doc/html/libpq-example.html
1

スキルアップ/キャリアアップ(JOB@IT)