Home Help Center

The ice include path...

hi,

i have question regarding including the ice files.

suppose i have a ice file... a.ice

module X {
module Y {
interface Z {
void doSomething(int x, int y);
};
};
};

and if i have a ice file b.ice in the same directory:

#include "a.ice"

module D {
module E {
interface F implements ::X::Y::Z {
void doSomething(int x, int y);
};
};
};


this does not work.

how do i include a sice file into another sice file

Comments

  • sac_urssac_urs Member
    The Ice include path

    and one more note on that,

    if i do slice2py, it compiles.
    and it does not work when i do Ice.loadSlice(path_to_icefile).

    thanks,
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    If Ice.loadSlice call is failing, could you cut and paste the error you're seeing when you run the python script? Note that you might need to specify the --all option when loading your Ice file (unless you have already generated definitions for the a.ice included file). For example:
      Ice.loadSlice("--all file.ice")
    

    Benoit.
  • sac_urssac_urs Member
    The ice include path

    hi here is the complete description of the problem:

    i have a ice file called category.ice in /opt/prh/prhPC/ice/prhice/ directory.
    in the same directory i have another file called utils.ice, which contains common code that would be present in all the ice files.

    so i do,

    #include "utils.ice" in all the files, so that i could use that common method getRowCount() every ice module without having to rewrite many times.

    but when i do a Ice.loadSlice("--all /opt/prh/....") , I get the following error.



    Traceback (most recent call last):
    File "categoryclient.py", line 6, in ?
    Ice.loadTraceback (most recent call last):
    File "categoryclient.py", line 6, in ?
    Ice.loadSlice('/opt/prh/prhPC/ice/prhice/category.ice')
    File "/opt/prh/prhPC/ice/prhice/category.ice", line 3, in ?

    ImportError: No module named _opt_prh_prhPC_ice_prhice_utils_ice
    Slice('/opt/prh/prhPC/ice/prhice/category.ice')
    File "/opt/prh/prhPC/ice/prhice/category.ice", line 3, in ?

    ImportError: No module named _opt_prh_prhPC_ice_prhice_utils_ice


    thanks,
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    It looks like Ice.loadSlice is not properly handling files included with #include "" (instead of #include <>). You should be able to work around this problem by using the following command instead:
       Ice.loadSlice("--all -I/opt/prh/prhPC/ice/prhice /opt/prh/prhPC/ice/prhice/category.ice")
    

    Benoit.
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    sac_urs wrote:
    but when i do a Ice.loadSlice("--all /opt/prh/....") , I get the following error.

    Traceback (most recent call last):
    File "categoryclient.py", line 6, in ?
    Ice.loadSlice('/opt/prh/prhPC/ice/prhice/category.ice')
    File "/opt/prh/prhPC/ice/prhice/category.ice", line 3, in ?

    ImportError: No module named _opt_prh_prhPC_ice_prhice_utils_ice
    Slice('/opt/prh/prhPC/ice/prhice/category.ice')
    File "/opt/prh/prhPC/ice/prhice/category.ice", line 3, in ?
    As Benoit mentioned, you need to include the '--all' option, otherwise the extension expects to find a statically-generated module for utils.ice (see section 22.15 in the manual).

    Take care,
    - Mark
  • sac_urssac_urs Member
    hi,

    the --all flag is working,
    thanks for the reply.

    thanks,
Sign In or Register to comment.