hello again.
is it possible to code the server side of DICE generated stubs using C++ by only modifing the filename and deleting the #ifdef __cplusplus? or is DICE ready to generate C++ code?
thanks
Tiago
Tiago Jorge wrote:
hello again.
is it possible to code the server side of DICE generated stubs using C++ by only modifing the filename and deleting the #ifdef __cplusplus? or is DICE ready to generate C++ code?
Please see http://article.gmane.org/gmane.comp.micro-kernel.l4.l4ka.general/748
Greetings, Ron.
Ronald AIGNER wrote:
Tiago Jorge wrote:
hello again.
is it possible to code the server side of DICE generated stubs using C++ by only modifing the filename and deleting the #ifdef __cplusplus? or is DICE ready to generate C++ code?
Please see http://article.gmane.org/gmane.comp.micro-kernel.l4.l4ka.general/748
Greetings, Ron.
thanks... that is a good article... and maybe i'll write an ORB if i have some spare time in the the end :). By now, i'm just trying to put C++ to work... but i'm having a little problem again. When i come to build the stubs it with g++, it gives me error in the lines that fill the exception in the call, more precisely here:
l4_umword_t _exception = ((dice_CORBA_exception_type){ _s: { .major = _dice_corba_env->major, .repos_id = _dice_corba_env->repos_id }})._raw;
it says:
/home/tiago/l4/pkg/ipc_example/server/src/hiworld-server.cc:17: error: parse error before `.' token
how can i adapt this line to C++ or... where is the "error".
thanks
Tiago
Hi, sorry for the delay.
Tiago Jorge said:
When i come to build the stubs it with g++, it gives me error in the lines that fill the exception in the call, more precisely here:
l4_umword_t _exception = ((dice_CORBA_exception_type){ _s: { .major = _dice_corba_env->major, .repos_id = _dice_corba_env->repos_id }})._raw;
it says:
/home/tiago/l4/pkg/ipc_example/server/src/hiworld-server.cc:17: error: parse error before `.' token
how can i adapt this line to C++ or... where is the "error".
I tried to find a solution to this. It seems that the above initializer is only valid in C. In C++ a struct is treated as a class and has therefore to be initialized like a class (that's what I am guessing). A temporary workaround would be to replace the above line with an explicit assignment of the structs members:
dice_CORBA_exception_type _exc_tmp; _exc_tmp._s.major = _dice_corba_env->major; _exc_tmp._s.repos_id = _dice_corba_env->repos_id; l4_umword_t _exception = _exc_tmp._raw;
Sorry, but currently that's the only solution I can come up with. Maybe a C++ guru can jump in?
Greetings, Ron.
Again,
Ronald Aigner said:
dice_CORBA_exception_type _exc_tmp; _exc_tmp._s.major = _dice_corba_env->major; _exc_tmp._s.repos_id = _dice_corba_env->repos_id; l4_umword_t _exception = _exc_tmp._raw;
I plaid around a bit and came up with the following. But there I am stuck...
dice_CORBA_exception_type _exc_tmp = { _exc_tmp._s.major = _dice_corba_env->major, _exc_tmp._s.repos_id = _dice_corba_env->repos_id }; l4_umword_t _exception = _exc_tmp._raw;
Greetings, Ron.
Ronald Aigner wrote:
Again,
Ronald Aigner said:
dice_CORBA_exception_type _exc_tmp; _exc_tmp._s.major = _dice_corba_env->major; _exc_tmp._s.repos_id = _dice_corba_env->repos_id; l4_umword_t _exception = _exc_tmp._raw;
I plaid around a bit and came up with the following. But there I am stuck...
dice_CORBA_exception_type _exc_tmp = { _exc_tmp._s.major = _dice_corba_env->major, _exc_tmp._s.repos_id = _dice_corba_env->repos_id }; l4_umword_t _exception = _exc_tmp._raw;
Greetings, Ron.
in the client there is also code like this...The solution is the following:
dice_CORBA_exception_type aux_exc; aux_exc._raw = _exception; _dice_corba_env->major = aux_exc._s.major; _dice_corba_env->repos_id = aux_exc._s.major;
Tiago
On Thu, 2005-03-31 at 10:20 +0100, Tiago Jorge wrote:
When i come to build the stubs it with g++, it gives me error in the lines that fill the exception in the call, more precisely here:
l4_umword_t _exception = ((dice_CORBA_exception_type){ _s: { .major = _dice_corba_env->major, .repos_id = _dice_corba_env->repos_id }})._raw;
it says:
/home/tiago/l4/pkg/ipc_example/server/src/hiworld-server.cc:17: error: parse error before `.' token
how can i adapt this line to C++ or... where is the "error".
This is a DICE bug -- or rather, an unintended C++ incompatibility.
The C99 standard introduced this syntax for "struct initialization by name". It has not been accepted into the C++ language (yet), and I sincerely hope that it will never be. The C99 specification of this behavior is extremely complex and filled with ambiguity. It fails, for example, to specify the order of initialization, and it is legal using the by name initializers to initialize a field twice -- once in the old style and a second time using the new syntax. The results are both unchecked and unspecified.
Because this area of the C99 standard is exceedingly complicated, I would strongly urge the DICE team to avoid use of this feature. There is nothing conceptually wrong with it, but current compilers cannot be relied on to implement this feature correctly in complex cases. Using this feature is therefore inadvisable *even* if C is the only intended target langauge.
Avoiding it would incidentally avoid a gratuitous C++ incompatibility, and would help ensure that all initializers are completely specified by making it impossible to omit fields accidentally from the initialization specification.
Jonathan Shapiro
l4-hackers@os.inf.tu-dresden.de