www.digitalmars.com         C & C++   DMDScript  

c++.wxwindows - DMC++ build of wxWindows app and broken cmd line arguments

reply Matt Morgan <geckofood yahoo.com> writes:
I have an application that I have been working on for quite a
while. It's a simple creative writing application, though the
specifics are not important except for one detail - the
application looks for an INI file in the same directory as the
executable.

My method for finding it is to grab argv[ 0 ], parse it to get
just the directory, and then append the INI file name. This almost
works...

When I compile my application with either Microsoft's or Borland's
compiler this works just fine, but when I compile with DMC++ argv[
0 ] is full of garbage. wxApp::argv[ 0 ] and just argv[ 0 ] give
the same result.

Is there a suitable workaround for this? I *could* set a registry
value and go at it that way, but I would just as soon not mess
with the registry - I am trying to make this thing as portable and
flexible as possible and as soon as I start messing with registry
keys it breaks all of that. I could also hardcode the directory,
but that makes it impossible to install the application anywhere
other than the default, and I had a request to make the
application more flexible in that regard.

Any and all suggestions are welcome.
Sep 12 2007
next sibling parent Matt Morgan <geckofood yahoo.com> writes:
I did manage to find a workaround, by using a call to wxGetCwd, so
I am not dead in the water anymore. However, this does not answer
the question as to why argv[0] is messed up when I build with
DMC++...
Sep 13 2007
prev sibling parent Cesar Rabak <crabak acm.org> writes:
Matt Morgan escreveu:
 I have an application that I have been working on for quite a
 while. It's a simple creative writing application, though the
 specifics are not important except for one detail - the
 application looks for an INI file in the same directory as the
 executable.
 
 My method for finding it is to grab argv[ 0 ], parse it to get
 just the directory, and then append the INI file name. This almost
 works...
 
 When I compile my application with either Microsoft's or Borland's
 compiler this works just fine, but when I compile with DMC++ argv[
 0 ] is full of garbage. wxApp::argv[ 0 ] and just argv[ 0 ] give
 the same result.
 
It must be some interaction with wxWindows library: If I compile this code for a NT console app: #include <iostream> int main(int argc, char *argv[]) { std::cout << "My name is " << argv[0] << "\n"; } And then run it from a command prompt, I get the following in my machine (Win XP SP2): D:\DM\SAMPLES>alo-cpp My name is D:\DM\SAMPLES\alo-cpp.EXE [snipped]
 
 Any and all suggestions are welcome.
Sep 13 2007