I am trying to use the Console::SetCursorPosition(int, int) method. When I add the line using namespace System;
, as shown in the C++ example from the preceding MSDN documentation, I get the error "Error: name must be a namespace name"
. I have been trying stuff for a couple hours now, but frustratingly without success. I have come across a ton of documentation for Visual Studio 2010 and 2012, but very little for 2013. The closest I have come is Lib Files as Linker Input. Steps 1-3 are easy enough, but step 4 is not clear to me: "Modify the Additional Dependencies property.". Looking at what is already there, it seems like I can just add a .lib file. But I don't have a System.lib.
So frustrated, so confused.
How can I use the System namespace in Visual Studio 2013 Update 4 for C++?
To formalize and expand on my comment, the Console
class and generally the System
namespace are part of the .NET framework.
In that context, the "C++" tab included in the MSDN documentation page of the Console::SetCursorPosition(int, int) method actually refers to the C++/CLI language. The C++/CLI language is distinct (although intentionally similar) from the C++ language. Correspondingly, the C++/CLI language contains various constructs which are not recognized by the C++ compiler toolset used when compiling Win32 projects.
In other words, to get rid of the "Error: name must be a namespace name"
error, you would need to convert your Win32 C++ project to a CLR project. The easiest way to do that would be to create a new project, selecting one of the templates under "Visual C++" / "CLR":
The equivalent of .lib file depdendencies (relative to your Lib Files as Linker Input link) of Win32 projects for CLR project would be assembly references. You'd then typically add those assembly references with "Add References" under "Common Properties , References" project properties:
However, in your specific case you may very well find out that the System
assembly reference is already included as part of the CLR project template.
You may want to check How to: Add or Remove References on MSDN for more details.
Finally, if you absolutely want to manually convert an existing Win32 project, you would need to set the "Common Language Runtime Support" project properties under "General" and the "C/C++ , General" tabs to one of /clr
, /clr:pure
, /clr:safe
or /clr:oldSyntax
(depending on your specific application requirements; if you're just toying around you might want to start with /clr
) for all Configurations and Platforms as well as specify the targeted .Net framework version by directly editing the .vcxproj (as indicated in this answer). You would also still need to add assembly dependencies as with the new project approach above.
You have to set Common Language Runtime Support (/clr)
in Configuration Properties - General:
And in Configuration Properties - C/C++ - General:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With