Archived

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

Help! slice2cpp fail in win2000 command-line

happy new year!

i tried to use slice2cpp(ice-2.0.0) in windows2000 command-line, but failed, it is a bug? pls help me!thanks u!

===================
E:\Projects\Demo> slice2cpp --include-dir Demo --output-dir E:\Projects\Demo\build\generated -IE:\Projects\Demo\slice --dll-export DEMO_API E:\Projects\Demo\slice\DemoInterface.ice

output:
slice2cpp: can't open `E:\Projects\Demo\build\generated\/E:\Projects\Demo\slice\DemoInterface.h' for writing


source code from slice2cpp\Gen.cpp:
Slice::Gen::Gen(const string& name, const string& base, const string& headerExtension,
const string& sourceExtension, const string& include, const vector<string>& includePaths,
const string& dllExport, const string& dir, bool imp, bool checksum, bool stream) :
_base(base),
_headerExtension(headerExtension),
_sourceExtension(sourceExtension),
_include(include),
_includePaths(includePaths),
_dllExport(dllExport),
_impl(imp),
_checksum(checksum),
_stream(stream)
{
...

string::size_type pos = _base.rfind('/');
if(pos != string::npos)
{
_base.erase(0, pos + 1);
}

...

string fileH = _base + "." + _headerExtension;
string fileC = _base + "." + _sourceExtension;
if(!dir.empty())
{
fileH = dir + '/' + fileH;
fileC = dir + '/' + fileC;
}

H.open(fileH.c_str());
if(!H)
{
cerr << name << ": can't open `" << fileH << "' for writing" << endl;
return;
}

C.open(fileC.c_str());
if(!C)
{
cerr << name << ": can't open `" << fileC << "' for writing" << endl;
return;
}

...

}



i think follow code is the key?!

string::size_type pos = _base.rfind('/'); // pos== string::npos

in windows, file separator is '\', but not '/', so the code below run incorrectly, and cause the fail as mention.
string fileH = _base + "." + _headerExtension;
string fileC = _base + "." + _sourceExtension;
if(!dir.empty())
{
fileH = dir + '/' + fileH;
fileC = dir + '/' + fileC;
}

it is right?help!

Comments

  • mes
    mes California
    Welcome!

    Thanks for reporting this. You will need to use forward slashes instead:

    > slice2cpp --include-dir Demo --output-dir E:/Projects/Demo/build/generated -IE:/Projects/Demo/slice --dll-export DEMO_API E:/Projects/Demo/slice/DemoInterface.ice

    Take care,
    - Mark
  • Thank mes! it is ok now:)