Archived

This forum has been archived. Please start a new discussion on GitHub.

slice2cpp output that won't compile

Here is a simple example that fails. I am running RedHat 9 with all
patches. The problem seems to be that the __F__Control class is
defined twice in test.cpp outside of any namespace. Thus the two Control
classes cause the generation of conflicting names.
I originally ran into this with the conflicting classes in two separate
ice files. That results in a segmentation fault in a runtime static
constructor.
Am I breaking some Ice coding rule?
By the way, this all works in Java.

I am using a recent download of Ice 1.4.0. I also see this
in 1.3.0.

Jim

cat test.ice

#ifndef TEST_ICE
#define TEST_ICE
module A {
class Control {
string name;
};
};
module B {
class Control {
double a;
};
};
#endif

slice2cpp test.ice

c++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

c++ -g -pipe -ftemplate-depth-128 -fPIC -Wall -D_REENTRANT -I. -I$ICE_HOME/include -c test.cpp
test.cpp:449: redefinition of `class __F__Control'
test.cpp:286: previous definition of `class __F__Control'
test.cpp:449: confused by earlier errors, bailing out

Comments

  • mes
    mes California
    Hi,

    Thanks for the bug report! This problem has been fixed for the next release. Until then, I've attached a patch that you can apply to correct it. Assuming you've saved the patch in the file $ICE_HOME/patch.txt, you can apply it like this:

    $ cd $ICE_HOME
    $ patch -p0 < patch.txt

    Next you need to rebuild the translator. You can do this by running make in the top-level Ice directory, but due to dependency rules the change to slice2cpp will cause everything to be rebuilt. Alternatively, you can change to the src/slice2cpp directory and run make there to build only the new translator binary.

    Take care,
    - Mark