visual studio 2010 - Command-Line arguments not working (char, TCHAR) VS2010 -
i have following code:
int _tmain(int argc, char** argv) { bool g_graphics = true; palphysics * pp = 0; #ifndef pal_static pf -> loadpalfromdll(); #endif char a[] = "bullet"; std::string aa; aa = std::string(argv[1]); //pf->selectengine("bullet"); debugbreak(); pf -> selectengine(argv[1]); //pf->selectengine(aa); //debug // assert(false); pp = pf -> createphysics(); }
i trying read in command line argument no. 1 in line:
pf->selectengine(argv[1]);
however, first letter of argument. have tried changing
int _tmain(int argc, char** argv)
to
int _tmain(int argc, tchar** argv),
error:
error c2664: 'palfactory::selectengine' : cannot convert parameter 1 'tchar *' 'const pal_string &'
pal_string std::string.
this might simple one, not sure how convert tchar std::string, since tchar else depending on compiler /environment settings. aware of easy way command-line arguments work, such don't need convert myself, i..e maybe changing tmain function?
thanks!
c
update: example of invoking on command line:
yep. way invoke on command line is:
progname.exe arg1 arg2,
where arg1 physics engine trying load, , arg2 dae(physics file physics info), go, specifically:
progname.exe bullet e:/a.dae
stepping line "pf->selectengine(argv[1]);" gives following code:
bool palfactory::selectengine(const pal_string& name) { #ifdef internal_debug printf("palfactory::selectengine: = %p\n", this); #endif setactivegroup(name); // calls rebuildregistry return isclassregistered("palphysics"); }
, in case, when debugging, can see const pal_string& name, i.e. string, "b", instead of expect be, "bullet", command line argument have passed in command line.
i've been plauged problem years. solution i've been able find not use visual studio. i've had fall using other compilers when must able process command-line args. specifically, i've been using digital mars compiler successfully. handles command-line args correctly. use vs environment intellisense , debugging, compile dmc deploy.
---edit below---
turns out, wasn't asking right question. asked right question, , got right answer! see link below.
Comments
Post a Comment