| | |
How to do basic file I/O in Visual C++ or in Visual C++ .NET
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
Has anyone tried to write this tutorial using VC++ 2008 Express? The article claims to be written with VC++ 2005. But I thought 2005 and 2008 used compatible versions of CLR language. I'm getting all kinds of compiler errors -- for example
String* str; instead of using String^ str; and creating objects with new instead of gcnew. The last straw for me was while attempting to implement the section concerning FileInfo class. None of the FileInfo methods Microsoft has in that article work. Last edited by Ancient Dragon; Jul 7th, 2009 at 3:12 pm.
The tutorial tells you what to do to compile as Managed C++ instead of C++/CLI:
•
•
•
•
Note In Visual C++ 2005, you must add the common language runtime support compiler option (/clr:oldSyntax) to successfully compile the previous code sample as Managed C++. To add the common language runtime support compiler option, follow these steps:
- Click Project, and then click ProjectName Properties.
Note ProjectName is a placeholder for the name of the project.- Expand Configuration Properties, and then click General.
- In the right pane, click to select Common Language Runtime Support, Old Syntax (/clr:oldSyntax) in the Common Language Runtime support project settings.
- Click Apply, and then click OK.
For more information about common language runtime support compiler options, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/k8d11d4s.aspx (http://msdn2.microsoft.com/en-us/library/k8d11d4s.aspx)
-Tommy (For Great Justice!) Gunn
When I change that I get this warning
Then get other errors, such as this one (line 19 in the code shown below).
Form1.h(22) : error C2059: syntax error : 'public'
•
•
•
•
1>cl : Command line warning D9035 : option 'clr:oldsyntax' has been deprecated and will be removed in a future release
Form1.h(22) : error C2059: syntax error : 'public'
C++ Syntax (Toggle Plain Text)
namespace test5 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; /// <summary> /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); <snip>
Last edited by Ancient Dragon; Jul 7th, 2009 at 3:48 pm.
That looks like generated C++/CLI code. None of that fancy stuff will work under the oldSyntax setting. You have to start with an empty project and build it manually, I think. Or find a tutorial that covers the new syntax. The MSDN library has example code in multiple langauges for all of the classes in System::IO and they are up to date for the framework version. C++/CLI is always included from what I've seen. For example.
Last edited by Tom Gunn; Jul 7th, 2009 at 4:00 pm.
-Tommy (For Great Justice!) Gunn
![]() |
Similar Threads
- Differance Between Visual C++ and C++.NET (C++)
- How to Create Log File Visual C++ (C++)
- Creating a .exe file w/ Visual C++ Express (C++)
- K&R with Visual C++.net version 2003 (C)
- opening excel file in visual basic 6 (Visual Basic 4 / 5 / 6)
- how to create a exe file in visual C++ (C++)
- open a PDF file in visual basic (Visual Basic 4 / 5 / 6)
- Learning Visual C++ .net 2003 (C++)
- programming in C using Visual C++.net (C++)
Other Threads in the C++ Forum
- Previous Thread: c++ application deployment
- Next Thread: "Assertion Failed. Expression 'stream != NULL' "
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






