Re: C++ Bindings Generate static const Code that will not Compile



lgust verizon net wrote:

Why does ORBit2 generated a static const char * data member of a class, which will not compile with gcc 3.2?
It is a bug. I have applied a patch to in cvs. Can you please upgrade to the latest version of orbitcpp in CVS and confirm that the patch works for you.

The C++ standard states that it is legal to initialize static const data members in a class that are enumerated or integral types.
It is a shame they ruled out non-integral constants. Fortunately for lazy people like me GCC copes with non-integral constants in headers.

The C++ Standard ISO/IEC 14882:1998(E) on page 158 states: “If a static data member is of const integral or const enumeration type, its declaration in the class definition can specify a constant-initializer which shall be an integral constant expression.”

Since the generated statement is not of integral nor enumeration type, this statement generates the following errors when compiled by gcc 3.2:

gcc -c -g -DORBIT2=1 -D_REENTRANT -I/home/nfr/local/include/orbit-2.0 -I/home/nfr/local/include/linc-1.0 -I/home/nfr/local/include/glib-2.0 -I/home/nfr/local/lib/glib-2.0/include -I/home/nfr/local/include/orbitcpp-2.0 client.cc
In file included from cf-cpp-stubs.h:11,
                from client.cc:3:
cf-cpp-common.h:46: invalid in-class initialization of static data member of non-integral type `const char*'
For GCC (at least) the problem is not that the string is of non integral type, but that the string is not constant. The type should be const char* const rather than const char*. I have changed this in CVS.

Is the syntax of the IDL file incorrect? If it is correct, then why does ORBit2 generated C++ code that will not compile?
Your IDL was fine, so it is a bug in orbitcpp. If the idl file is syntactically correct, the backend should generate legal C++ code. Any time legit IDL generates bad C++ is pretty much going to be either a bug. Please continue to report problems as you find them.


--
Bowie Owens

CSIRO Mathematical & Information Sciences
phone  : +61 3 9545 8055
fax    : +61 3 9545 8080
mobile : 0425 729 875
email  : Bowie Owens csiro au






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