mscorlib.dll problem (Visual C++ 2005)

A

Alex Hardin

Hey,
I just downloaded Visual C++ 2005 Express, and I'm reading through a
book called "Visual C++ .NET Step By Step", which was made for 2003.
Just so you know where I'm getting this example.

When I build this code, I get the following compile error.

1>c:\documents and settings\editing\my
documents\alex\c++\animal\animal\animal.cpp(6) : fatal error C1190:
managed targeted code requires a '/clr' option

And that is regarding this:

#using <mscorlib.dll>

And then when I had /clr to the options, it then says:

1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line
options are incompatible

So if I shut off /RTC1 in code generation, then it just says that
therer is another thing incompatible (/Gm I think) and it just keeps
going on with incompatibilities. Is there any way that I can make this
code work?

////////////////////////////////////////////////////////////////////////

// Animal.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#using <mscorlib.dll>

using namespace System;

__gc class Animal
{
public:
int legs;
void SetName(String *name)
{ strName = strName->Copy(name); }
String* GetName() { return strName; }
private:
String *strName;
};


int _tmain()
{
Animal *cat, *dog;
cat = new Animal;
dog = new Animal;

cat->SetName("Cat");
cat->legs = 4;
dog->SetName("Dog");
dog->legs = 4;

Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName());
Console::Write("Legs: ");
Console::Write(cat->legs);

return 0;
}

//////////////////////////////////////////////////////

I am using a regular Win32 console applications. Thanks alot.
 
J

John Carson

Alex Hardin said:
Hey,
I just downloaded Visual C++ 2005 Express, and I'm reading through a
book called "Visual C++ .NET Step By Step",

Judging by the reviews on Amazon, it is a dreadful book.
which was made for 2003.
Just so you know where I'm getting this example.
When I build this code, I get the following compile error.

1>c:\documents and settings\editing\my
documents\alex\c++\animal\animal\animal.cpp(6) : fatal error C1190:
managed targeted code requires a '/clr' option

And that is regarding this:

#using <mscorlib.dll>

And then when I had /clr to the options, it then says:

1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line
options are incompatible

So if I shut off /RTC1 in code generation, then it just says that
therer is another thing incompatible (/Gm I think) and it just keeps
going on with incompatibilities. Is there any way that I can make
this code work?

////////////////////////////////////////////////////////////////////////

// Animal.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#using <mscorlib.dll>

using namespace System;

__gc class Animal
{
public:
int legs;
void SetName(String *name)
{ strName = strName->Copy(name); }
String* GetName() { return strName; }
private:
String *strName;
};


int _tmain()
{
Animal *cat, *dog;
cat = new Animal;
dog = new Animal;

cat->SetName("Cat");
cat->legs = 4;
dog->SetName("Dog");
dog->legs = 4;

Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName());
Console::Write("Legs: ");
Console::Write(cat->legs);

return 0;
}

//////////////////////////////////////////////////////

I am using a regular Win32 console applications. Thanks alot.



The example involves managed code, which is a non-standard Microsoft
extension to C++ (and hence off-topic on this
newsgroup). Incidentally, the version of managed code supported by VC++ 2003
(and discussed in the book you have) is effectively obsolete, replaced by
C++/CLI in VC++ 2005.

The correct place to ask about this stuff is

microsoft.public.dotnet.languages.vc
 
A

Alex Hardin

Okay thanks, I did get the problem fixed on the other group. I didn't
read anything about the book, I just saw it at the library and picked
it up. I'll try and look for a 2005 book then. Or something. Thanks
again guys.
 
M

Michiel.Salters

Alex said:
Okay thanks, I did get the problem fixed on the other group. I didn't
read anything about the book, I just saw it at the library and picked
it up. I'll try and look for a 2005 book then.

You probably don't want to look at all the 2005 extensions before
learning
the base language proper. Have a look at www.accu.org. It has a lot of
book
reviews, rated by experts. One of the better books is Accelerated C++,
by
A.Koenig. It's good for novices, either new to C++ or to programming in

general. If you're one of the latter, don't be fooled by the thin
appearance.
It's complete, but has little fluff.

HTH,
Michiel Salters
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top