LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 984|回复: 0

问一下关于g++的两个参数

[复制链接]
发表于 2005-5-1 18:18:40 | 显示全部楼层 |阅读模式
-DHAVA_NAMESPACE_STD和-DDLLIMPORT

当我输入下面的命令的时候可以编译通过:
  1. g++  -DHAVE_NAMESPACE_STD  -DDLLIMPORT="" -I/usr/local/pgsql/include -o cpptest cpptest.cc -L/usr/local/pgsql/lib -lpq++
复制代码


如果把-DHAVE_NAMESPACE_STD和-DDLLIMPORT=""去掉(或去掉任何一个)就会出现如下错误:

  1. In file included from /usr/local/pgsql/include/libpq++.h:30,
  2.                  from cpptest.cc:2:
  3. /usr/local/pgsql/include/libpq++/pgconnection.h:49: syntax error before `{'
  4.    token
  5. /usr/local/pgsql/include/libpq++/pgconnection.h:55: syntax error before `public
  6.    '
  7. /usr/local/pgsql/include/libpq++/pgconnection.h:57: destructors must be member
  8.    functions
  9. /usr/local/pgsql/include/libpq++/pgconnection.h:57: virtual outside class
  10.    declaration
  11. /usr/local/pgsql/include/libpq++/pgconnection.h:60: non-member function `
  12.    ConnStatusType Status()' cannot have `const' method qualifier
  13. /usr/local/pgsql/include/libpq++/pgconnection.h:61: non-member function `bool
  14.    ConnectionBad()' cannot have `const' method qualifier
  15. /usr/local/pgsql/include/libpq++/pgconnection.h:62: non-member function `const
  16.    char* ErrorMessage()' cannot have `const' method qualifier
  17. /usr/local/pgsql/include/libpq++/pgconnection.h:65: non-member function `const
  18.    char* DBName()' cannot have `const' method qualifier
  19. /usr/local/pgsql/include/libpq++/pgconnection.h:76: syntax error before `
  20.    protected'
  21. /usr/local/pgsql/include/libpq++/pgconnection.h:79: syntax error before `('
  22.    token
  23. /usr/local/pgsql/include/libpq++/pgconnection.h:81: ISO C++ forbids declaration
  24.    of `PgConnection' with no type
  25. /usr/local/pgsql/include/libpq++/pgconnection.h:81: new declaration `int
  26.    PgConnection()'
  27. /usr/local/pgsql/include/libpq++/pgconnection.h:57: ambiguates old declaration
  28.    `void PgConnection()'
  29. /usr/local/pgsql/include/libpq++/pgconnection.h:83: syntax error before `
  30.    private'
  31. /usr/local/pgsql/include/libpq++/pgconnection.h:87: syntax error before `&'
  32.    token
  33. In file included from /usr/local/pgsql/include/libpq++.h:31,
  34.                  from cpptest.cc:2:
  35. /usr/local/pgsql/include/libpq++/pgdatabase.h:37: syntax error before `:' token
  36. /usr/local/pgsql/include/libpq++/pgdatabase.h:45: destructors must be member
  37.    functions
  38. /usr/local/pgsql/include/libpq++/pgdatabase.h:51: non-member function `
  39.    size_type Tuples()' cannot have `const' method qualifier
  40. /usr/local/pgsql/include/libpq++/pgdatabase.h:52: non-member function `
  41.    size_type CmdTuples()' cannot have `const' method qualifier
  42. /usr/local/pgsql/include/libpq++/pgdatabase.h:54: non-member function `const
  43.    char* FieldName(int)' cannot have `const' method qualifier
  44. /usr/local/pgsql/include/libpq++/pgdatabase.h:55: non-member function `int
  45.    FieldNum(const char*)' cannot have `const' method qualifier
  46. /usr/local/pgsql/include/libpq++/pgdatabase.h:56: non-member function `Oid
  47.    FieldType(int)' cannot have `const' method qualifier
  48. /usr/local/pgsql/include/libpq++/pgdatabase.h:57: non-member function `Oid
  49.    FieldType(const char*)' cannot have `const' method qualifier
  50. /usr/local/pgsql/include/libpq++/pgdatabase.h:58: non-member function `int
  51.    FieldSize(int)' cannot have `const' method qualifier
  52. /usr/local/pgsql/include/libpq++/pgdatabase.h:59: non-member function `int
  53.    FieldSize(const char*)' cannot have `const' method qualifier
  54. /usr/local/pgsql/include/libpq++/pgdatabase.h:60: non-member function `const
  55.    char* GetValue(int, int)' cannot have `const' method qualifier
  56. /usr/local/pgsql/include/libpq++/pgdatabase.h:61: non-member function `const
  57.    char* GetValue(int, const char*)' cannot have `const' method qualifier
  58. /usr/local/pgsql/include/libpq++/pgdatabase.h:62: non-member function `bool
  59.    GetIsNull(int, int)' cannot have `const' method qualifier
  60. /usr/local/pgsql/include/libpq++/pgdatabase.h:63: non-member function `bool
  61.    GetIsNull(int, const char*)' cannot have `const' method qualifier
  62. /usr/local/pgsql/include/libpq++/pgdatabase.h:64: non-member function `int
  63.    GetLength(int, int)' cannot have `const' method qualifier
  64. /usr/local/pgsql/include/libpq++/pgdatabase.h:65: non-member function `int
  65.    GetLength(int, const char*)' cannot have `const' method qualifier
  66. /usr/local/pgsql/include/libpq++/pgdatabase.h:69: non-member function `void
  67.    DisplayTuples(FILE*, bool, const char*, bool, bool)' cannot have `const'
  68.    method qualifier
  69. /usr/local/pgsql/include/libpq++/pgdatabase.h:71: non-member function `void
  70.    PrintTuples(FILE*, bool, bool, bool)' cannot have `const' method qualifier
  71. /usr/local/pgsql/include/libpq++/pgdatabase.h:76: non-member function `const
  72.    char* OidStatus()' cannot have `const' method qualifier
  73. /usr/local/pgsql/include/libpq++/pgdatabase.h:79: syntax error before `
  74.    protected'
  75. /usr/local/pgsql/include/libpq++/pgdatabase.h:88: syntax error before `&' token
  76. In file included from /usr/local/pgsql/include/libpq++.h:32,
  77.                  from cpptest.cc:2:
  78. /usr/local/pgsql/include/libpq++/pglobject.h:38: syntax error before `:' token
  79. /usr/local/pgsql/include/libpq++/pglobject.h:43: 'string' is used as a type,
  80.    but is not defined as a type.
  81. /usr/local/pgsql/include/libpq++/pglobject.h:46: syntax error before `public'
  82. /usr/local/pgsql/include/libpq++/pglobject.h:48: ISO C++ forbids declaration of
  83.    `PgLargeObject' with no type
  84. /usr/local/pgsql/include/libpq++/pglobject.h:48: only declarations of
  85.    constructors can be `explicit'
  86. /usr/local/pgsql/include/libpq++/pglobject.h:49: destructors must be member
  87.    functions
  88. /usr/local/pgsql/include/libpq++/pglobject.h:57: non-member function `int
  89.    Tell()' cannot have `const' method qualifier
  90. /usr/local/pgsql/include/libpq++/pglobject.h:62: syntax error before `)' token
  91. /usr/local/pgsql/include/libpq++/pglobject.h:68: syntax error before `&' token
  92. In file included from /usr/local/pgsql/include/libpq++.h:33,
  93.                  from cpptest.cc:2:
  94. /usr/local/pgsql/include/libpq++/pgtransdb.h:38: syntax error before `:' token
  95. /usr/local/pgsql/include/libpq++/pgtransdb.h:44: destructors must be member
  96.    functions
  97. /usr/local/pgsql/include/libpq++/pgtransdb.h:49: syntax error before `protected
  98.    '
  99. /usr/local/pgsql/include/libpq++/pgtransdb.h:59: syntax error before `&' token
  100. /usr/local/pgsql/include/libpq++/pgtransdb.h:59: ISO C++ forbids declaration of
  101.    `PgTransaction' with no type
  102. /usr/local/pgsql/include/libpq++/pgtransdb.h:60: syntax error before `&' token
  103. In file included from /usr/local/pgsql/include/libpq++.h:34,
  104.                  from cpptest.cc:2:
  105. /usr/local/pgsql/include/libpq++/pgcursordb.h:44: syntax error before `:' token
  106. /usr/local/pgsql/include/libpq++/pgcursordb.h:50: destructors must be member
  107.    functions
  108. /usr/local/pgsql/include/libpq++/pgcursordb.h:53: `string' was not declared in
  109.    this scope
  110. /usr/local/pgsql/include/libpq++/pgcursordb.h:53: syntax error before `,' token
  111. /usr/local/pgsql/include/libpq++/pgcursordb.h:56: new declaration `int Close()'
  112. /usr/local/pgsql/include/libpq++/pglobject.h:53: ambiguates old declaration `
  113.    void Close()'
  114. /usr/local/pgsql/include/libpq++/pgcursordb.h:60: non-member function `const
  115.    char* Cursor()' cannot have `const' method qualifier
  116. /usr/local/pgsql/include/libpq++/pgcursordb.h: In function `const char*
  117.    Cursor()':
  118. /usr/local/pgsql/include/libpq++/pgcursordb.h:61: `pgCursor' undeclared (first
  119.    use this function)
  120. /usr/local/pgsql/include/libpq++/pgcursordb.h:61: (Each undeclared identifier
  121.    is reported only once for each function it appears in.)
  122. /usr/local/pgsql/include/libpq++/pgcursordb.h: At global scope:
  123. /usr/local/pgsql/include/libpq++/pgcursordb.h:65: `string' was not declared in
  124.    this scope
  125. /usr/local/pgsql/include/libpq++/pgcursordb.h:65: syntax error before `)' token
  126. /usr/local/pgsql/include/libpq++/pgcursordb.h: In function `void Cursor(...)':
  127. /usr/local/pgsql/include/libpq++/pgcursordb.h:67: `cursor' undeclared (first
  128.    use this function)
  129. /usr/local/pgsql/include/libpq++/pgcursordb.h: At global scope:
  130. /usr/local/pgsql/include/libpq++/pgcursordb.h:70: syntax error before `
  131.    protected'
  132. /usr/local/pgsql/include/libpq++/pgcursordb.h:85: syntax error before `&' token
  133. cpptest.cc: In function `int main()':
  134. cpptest.cc:8: `PgDatabase' undeclared (first use this function)
  135. cpptest.cc:8: syntax error before `(' token
  136. cpptest.cc:9: `data' undeclared (first use this function)
复制代码


请问这是为什么? :confused:  :confused:  :confused:

下面是我的代码:

  1. /** cpptest.cc*/
  2. #include <iostream>
  3. #include <libpq++.h>

  4. using namespace std;

  5. int  main() {
  6.         char query_string[256]= "SELECT * FROM v;";
  7.         PgDatabase data("dbname = test");
  8.         if (data.ConnectionBad()) {
  9.                 cout <<"connected failed" << endl;
  10.                 cout <<"Error is "<<data.ErrorMessage() << endl;
  11.         exit(1);
  12.     }
  13.     if (! data.ExecTuplesOk(query_string)) {
  14.                 cout<<"Query Failed!" << endl;
  15.                 exit(1);
  16.     }
  17.     for(int k=0; k<data.Fields(); k++) /**显示字段名称*/ {
  18.         cout<<data.FieldName(k);
  19.         cout <<"      "     ;
  20.     }
  21.     cout<<endl;
  22.     for (int i = 0; i < data.Tuples(); i++) /**取得查询结果的记录数量*/  {
  23.         for(int k=0; k<data.Fields(); k++) {
  24.                 cout << data.GetValue(i,k);
  25.                 cout <<" | "     ;
  26.         }
  27.         cout<<endl;
  28.     }
  29.     return 0 ;
  30. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表