[omniORB] #include in .IDL file works incorrectly!!!
Sai-Lai Lo
S.Lo@orl.co.uk
19 Jan 1999 12:11:39 +0000
David,
I guess what you are trying to do is something like this in pure OMG IDL.
// File S.IDL
// OMG IDL
struct X {
string A;
char B;
};
// File MAIN.IDL
#include "S.IDL"
interface I {
X op();
};
The complication is you want the definition of struct X to be done in a
single source file for both COM and CORBA.
1. Remember, the IDL compiler handle all the #include files only as IDL
files so any C++ specific constructs in the files would not be
recognised.
2. I suppose it is a bug that the compiler translate something like this:
interface I {
#include "S.IDL"
X op();
};
into
#include "S.hh"
class I {
....
};
Hence relocate the #include out of the context it is used in the IDL.
However, it is difficult to detect this and generate #include in the
output at the right context.
3. I don't know if I have an answer to achieve what you want.
One possibility may be to define a single IDL file with appropriate
#if to separate OMG IDL specific and COM IDL specific part while
sharing as much as possible.
Regards,
Sai-Lai
>>>>> David Morgenlender writes:
> I'm trying to #include a .H file into my .IDL file. But the IDL compiler is
> having problems:
> 1. If I do the #include within an interface, I get a "can't parse statement"
> error & the compiler (omniidl2) crashes with a system exception.
> 2. So, for testing purposes, I moved the #include outside any interface & tried
> again. I preceded the #include with a typedef statement, defining a type used
> by the .H file. This compiled without error, but generated incorrect code, e.g.
> in the .HH file:
> a. The #include statement is put at the front of the .HH file, while the
> typedef is placed later, AFTER the #include, which requires it.
> b. The #include is for x.HH, when it should be for x.H.
> How can I get the IDL compiler to do what I need, which is handle a struct
> defined within an interface, via a .H file, placing a typedef before the struct?
> BTW, here's why I'm doing things this way ... I use the same struct in different
> apps, some of which use CORBA, some of which use COM, & some of which use both.
> The variables within the struct are carefully used so they generate compatible
> data for both CORBA & COM, assuming the typedef mentioned above is defined
> appropriately in both CORBA & COM .IDL files. I desperately want to avoid
> having to define 2 different structs for CORBA & COM ... this is a very large
> struct!!!
> So I'm #include'ing one .H into both my CORBA & COM IDL files. I want to do
> this within an interface, so the struct typedef is essentially given a different
> name for CORBA than for COM, since one app will have both definitions.
> If the CORBA IDL compiler cannot be made to work with this approach, can you
> suggest something better???
> =======================================================
> Dave Morgenlender
> e-mail: dmorgen@alum.mit.edu
> =======================================================
--
Dr. Sai-Lai Lo | Research Scientist
|
E-mail: S.Lo@orl.co.uk | Olivetti & Oracle Research Lab
| 24a Trumpington Street
Tel: +44 223 343000 | Cambridge CB2 1QA
Fax: +44 223 313542 | ENGLAND