Re: Dia plugins and C++



On Tue, Apr 30, 2002 at 06:47:25PM +0200, Cyrille Chepelov wrote:
You mean extern "C" { } ? The OP would have to export all routines expected
by a plug-in with "C" linkage as well. Basically, this means writing plain C
dia objects (OK, with the implementation being done in the temporary
variable of the expression "C++"), and have these also serve as a 
"C++ world-to-C world" translation layer. 

Of course, the linker stage may bring its own set of interesting problems.

      -- Cyrille
        Hi,

The linker stage is good, but as soon as I include C headers from Dia,
I'm running into problems. What I want to do is a new menuitem in Dia
main menu, which works a bit like the Diagram Tree. I need to create a
tree depending on the entities' inter connections.
Currently the new menu works, I can show and hide the window as I like.

The beginning of cast.cpp is like that:

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gtk/gtk.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "../../lib/intl.h"
#include "../preferences.h"
#include "../diagram.h"
#include "../diagram_tree.h"
#include "../diagram_tree_window.h"
#include "../diagram_tree_menu.h"
#ifdef __cplusplus
}
#endif /* __cplusplus */

#include "cast.h"

I tried without the extern "C" stuff (except in cast.h where it is
needed).

Here is the output of the compilation, when I include these Dia headers:

khorben shok:~/Projects/dia/app/Cast$ make
source='cast.cpp' object='cast.o' libtool=no \
depfile='.deps/cast.Po' tmpdepfile='.deps/cast.TPo' \
depmode=gcc /bin/sh ../../depcomp \
c++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../intl -I./../../lib
-I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include
-I/usr/X11R6/include -I/usr/include/gnome-1.0 -DNEED_GNOMESUPPORT_H
-I/usr/lib/gnome-libs/include -I/usr/include/gtk-1.2
-I/usr/include/glib-1.2 -I/usr/lib/glib/include -I/usr/X11R6/include
-DUNICODE_USE_SYSTEM_ICONV    -g -O2 -c -o cast.o `test -f cast.cpp ||
echo './'`cast.cpp
In file included from ../diagram.h:26,
                 from ../diagram_tree.h:28,
                 from ../diagram_tree_window.h:28,
                 from ../preferences.h:23,
                 from cast.cpp:14:
../../lib/object.h:28: use of enum `_ModifierKeys' without previous
declaration
In file included from ../../lib/object.h:33,
                 from ../diagram.h:26,
                 from ../diagram_tree.h:28,
                 from ../diagram_tree_window.h:28,
                 from ../preferences.h:23,
                 from cast.cpp:14:
../../lib/handle.h:22: use of enum `_HandleId' without previous
declaration
../../lib/handle.h:23: use of enum `_HandleType' without previous
declaration
../../lib/handle.h:24: use of enum `_HandleMoveReason' without previous
declaration
../../lib/handle.h:25: use of enum `_HandleConnectType' without previous
declaration
../../lib/handle.h:29: multiple definition of `enum _HandleId'
../../lib/handle.h:53: multiple definition of `enum _HandleType'
../../lib/handle.h:61: multiple definition of `enum _HandleMoveReason'
../../lib/handle.h:69: multiple definition of `enum _HandleConnectType'
In file included from ../diagram.h:26,
                 from ../diagram_tree.h:28,
                 from ../diagram_tree_window.h:28,
                 from ../preferences.h:23,
                 from cast.cpp:14:
../../lib/object.h:42: multiple definition of `enum _ModifierKeys'
In file included from ../diagram.h:32,
                 from ../diagram_tree.h:28,
                 from ../diagram_tree_window.h:28,
                 from ../preferences.h:23,
                 from cast.cpp:14:
../../lib/filter.h:36: warning: keyword 'export' not implemented and
will be ignored
make: *** [cast.o] Error 1


Great thanks for anyone who would help me!
Thanks already to Lars, Cyrille and Hans.

PS: another problem comes to my mind: according to Dia's license, as I'm hacking on simple shapes, shapes in 
a plug-in, and now additional features, do I have to share my work?
I do this for a company, which seems to be OK if the source code is opened, but asks for written permission 
for its use and redistribution...



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]