1

I'm having a very hard time at trying to do trivial things with Visual-generated C++ code. This is getting frustrating beyond expectation.

I'm accustomed at getting arguments from command line thanks to :

int main(int argc, char** argv)

OK, this works, at least as long as we stay in an ANSI world.

Now, Visual generates this :

int main(array<System::String ^> ^args)

I'm somewhat clueless as to how to work with this line. I've obviously tried to swap the unknown semantic with the more familiar one, but compilation fails. I've also been roaming Internet for an unreasonably large amount of time, finding many examples for this situation, but none of them ever worked...

[Edit] Small explanation on what i'm attempting to do : this is supposed to be a trivial yet a GUI program. It takes a filepath from command line argument, and write in it depending on options selected by the user on the GUI. So : it is not a CLI, It is a Windows Form.

5
  • Just for your reference, that thing is a handle (something like a "GC managed pointer") to a .NET array of handles to .NET strings, and it contains the arguments given to your application. Commented Nov 5, 2011 at 19:05
  • Well, i tried, but this is even worse. There is not even a 'main' function anywhere. Here is what looks closest to a main that i could find :int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
    – Cyan
    Commented Nov 5, 2011 at 19:09
  • @Cyan: This is a Windows subsystem application, and yes, WinMain is the entry point in this case. Commented Nov 5, 2011 at 19:23
  • Please note that a console application can create UI windows as well. That might be the fastest path to success, if you are most familiar with argc and argv.
    – Ben Voigt
    Commented Nov 6, 2011 at 19:41
  • ok, but can i remove the console itself ?
    – Cyan
    Commented Nov 7, 2011 at 15:07

1 Answer 1

5

You're creating a .NET project, and what you're seeing is C++/CLI, not C++. Create a native project (Win32 Application or something like that) instead.

9
  • Ya, Console App is the most likely match.
    – EvilTeach
    Commented Nov 5, 2011 at 19:07
  • Also, you may want to select "Empty project" if you don't want to deal with the TCHAR stuff for now. Commented Nov 5, 2011 at 19:10
  • I'm supposed to write a GUI. I can't produce a console text-only app.
    – Cyan
    Commented Nov 5, 2011 at 19:19
  • 1
    @Attract: C++/CLI is the name of the language, the CLI in it doesn't have anything to do with command-line interface. You need to decide whether you want to write native application, or .NET one. You can have GUI in either. Commented Nov 5, 2011 at 19:24
  • Well, this is supposed to be a trivial program. I don't mind if it is CLI or not, as long as i can get the command line argument. Everything else seems to look like standard C++. I did nothing specific, just created a "windows form" project with Visual.
    – Cyan
    Commented Nov 5, 2011 at 19:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.