libpreludedb: g++ compile error in header

Hauke Mehrtens <[email protected]> Fri, 18 Jun 2010 13:50:31 +0200
Newsgroups gmane.comp.security.ids.prelude.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------050200020104080203060907
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hallo,

we want to use the libpreludedb in our own softwrae to access the
prelude database. We are using C++ with the g++ compiler. We are
including some header files form the libpreludedb to use the C
functions. When compiling the stuff with c++ we get loots of error
messages. When compiling it with gcc it works, but we want to use c++
and not c.

The problems with new and operator in preludedb-sql.h could be fixed
with some code in our software or by renaming some parameter names in
the header file:

#define new stupid_new
#define operator stupid_operator
#include <libpreludedb/preludedb-sql.h>
#undef new
#undef operator

But the other errors are harder to fix.

The attached patch fixes some of the compile error but there are still
some compile errors in preludedb_error_check().

Hauke

-----------------------------
g++ -g -Wall -I../../../misc/tools -Wno-write-strings -std=3Dc++0x
-DEVENT_DISPATCHER_AMCP_C
-I../../../ag-architektur/trunk/src/communication/c_client/fmqlib -o
preludedb_query_dispatcher.o -c preludedb_query_dispatcher.c
In file included from preludedb_query_dispatcher.c:10:
/usr/include/libpreludedb/preludedb-sql.h:66: error: expected =E2=80=98,=E2=
=80=99 or
=E2=80=98...=E2=80=99 before =E2=80=98new=E2=80=99
/usr/include/libpreludedb/preludedb-sql.h:120: error: declaration of
=E2=80=98operator,=E2=80=99 as non-function
/usr/include/libpreludedb/preludedb-sql.h:120: error: expected =E2=80=98)=
=E2=80=99
before =E2=80=98idmef_criterion_value_t=E2=80=99
/usr/include/libpreludedb/preludedb-sql.h:120: error: expected
initializer before =E2=80=98idmef_criterion_value_t=E2=80=99
In file included from preludedb_query_dispatcher.c:11:
/usr/include/libpreludedb/preludedb-error.h: In function
=E2=80=98preludedb_error_t preludedb_error(preludedb_error_code_t)=E2=80=99=
:
/usr/include/libpreludedb/preludedb-error.h:64: error: cannot convert
=E2=80=98preludedb_error_code_t=E2=80=99 to =E2=80=98prelude_error_code_t=
=E2=80=99 for argument =E2=80=982=E2=80=99 to
=E2=80=98prelude_error_t prelude_error_make(prelude_error_source_t,
prelude_error_code_t)=E2=80=99
/usr/include/libpreludedb/preludedb-error.h: In function
=E2=80=98preludedb_error_t preludedb_error_verbose(preludedb_error_code_t=
, const
char*, ...)=E2=80=99:
/usr/include/libpreludedb/preludedb-error.h:75: error: cannot convert
=E2=80=98preludedb_error_code_t=E2=80=99 to =E2=80=98prelude_error_code_t=
=E2=80=99 for argument =E2=80=982=E2=80=99 to
=E2=80=98prelude_error_t prelude_error_verbose_make_v(prelude_error_sourc=
e_t,
prelude_error_code_t, const char*, char*)=E2=80=99
/usr/include/libpreludedb/preludedb-error.h: In function =E2=80=98prelude=
_bool_t
preludedb_error_check(preludedb_error_t, preludedb_error_code_t)=E2=80=99=
:
/usr/include/libpreludedb/preludedb-error.h:87: error: cannot convert
=E2=80=98bool=E2=80=99 to =E2=80=98prelude_bool_t=E2=80=99 in return
/usr/include/libpreludedb/preludedb-sql.h: In function =E2=80=98int
get_database_connection(preludedb_t*)=E2=80=99:
/usr/include/libpreludedb/preludedb-sql.h:66: error: too many arguments
to function =E2=80=98int preludedb_sql_new(preludedb_sql_t**)=E2=80=99

--------------050200020104080203060907
Content-Type: text/x-patch;
 name="0001-preludedb-fix-some-compile-errors-with-g.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0001-preludedb-fix-some-compile-errors-with-g.patch"

From 62fe43f1b157de781c48851e7b5c8be14227ce85 Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <[email protected]>
Date: Fri, 18 Jun 2010 13:45:50 +0200
Subject: [PATCH] preludedb: fix some compile errors with g++


Signed-off-by: Hauke Mehrtens <[email protected]>
---
 src/include/preludedb-error.h |    4 ++--
 src/include/preludedb-sql.h   |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/include/preludedb-error.h b/src/include/preludedb-error.h
index ab9b1a4..48ad6b8 100644
--- a/src/include/preludedb-error.h
+++ b/src/include/preludedb-error.h
@@ -61,7 +61,7 @@ typedef prelude_error_t preludedb_error_t;
 
 static inline preludedb_error_t preludedb_error(preludedb_error_code_t error)
 {
-        return (preludedb_error_t) prelude_error_make(PRELUDE_ERROR_SOURCE_PRELUDEDB, error);
+        return (preludedb_error_t) prelude_error_make(PRELUDE_ERROR_SOURCE_PRELUDEDB, (prelude_error_code_t)error);
 }
 
 
@@ -72,7 +72,7 @@ static inline preludedb_error_t preludedb_error_verbose(preludedb_error_code_t e
 	va_list ap;
 
 	va_start(ap, fmt);
-	ret = prelude_error_verbose_make_v(PRELUDE_ERROR_SOURCE_PRELUDEDB, error, fmt, ap);
+	ret = prelude_error_verbose_make_v(PRELUDE_ERROR_SOURCE_PRELUDEDB, (prelude_error_code_t)error, fmt, ap);
 	va_end(ap);
 
 	return ret;
diff --git a/src/include/preludedb-sql.h b/src/include/preludedb-sql.h
index c939a0e..b1a93f3 100644
--- a/src/include/preludedb-sql.h
+++ b/src/include/preludedb-sql.h
@@ -63,7 +63,7 @@ typedef struct preludedb_sql_table preludedb_sql_table_t;
 typedef struct preludedb_sql_row preludedb_sql_row_t;
 typedef struct preludedb_sql_field preludedb_sql_field_t;
 
-int preludedb_sql_new(preludedb_sql_t **new, const char *type, preludedb_sql_settings_t *settings);
+int preludedb_sql_new(preludedb_sql_t **newdb, const char *type, preludedb_sql_settings_t *settings);
 
 void preludedb_sql_destroy(preludedb_sql_t *sql);
 
@@ -117,7 +117,7 @@ int preludedb_sql_field_to_string(preludedb_sql_field_t *field, prelude_string_t
 int preludedb_sql_build_criterion_string(preludedb_sql_t *sql,
 					 prelude_string_t *output,
 					 const char *field,
-					 idmef_criterion_operator_t operator, idmef_criterion_value_t *value);
+					 idmef_criterion_operator_t idmef_operator, idmef_criterion_value_t *value);
 
 int preludedb_sql_time_from_timestamp(idmef_time_t *time, const char *time_buf, int32_t gmtoff, uint32_t usec);
 int preludedb_sql_time_to_timestamp(preludedb_sql_t *sql,
-- 
1.7.0.4


--------------050200020104080203060907
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Prelude-devel site list
[email protected]
http://lists.prelude-technologies.com/mailman/listinfo/prelude-devel
--------------050200020104080203060907--