Really basic MC++ compilation error

T

Tommy Vercetti

In Visual Studio .NET 2003, I do the following
1) File->New->Project
2) Visual C++ Projects->.NET->Windows Forms Application
3) Project->Add New Item->C++ File
4) Clear the new C++ file and replace with the two lines:
#include "stdafx.h"
#include <vcclr.h>
5) Build->Build Solution

I get the following compilation errors:
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\stddef.h(28) : error C2144: syntax error : 'int' should
be preceded by ';'
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\stddef.h(28) : error C2501: 'p' : missing storage-class
or type specifiers

What do I do? I want to use the gcroot class. Has anyone done so
successfully?

I must say, that so far, converting to Managed C++ has been very
problematic and difficult:
1) Can't use a dynamically linked MFC/runtime
2) Hence I can't use many third party DLLs, namely Boost which VS 2003
has such widely touted compatibility with.
3) Many obscure, confusing, and difficult to diagnose compilation/link
errors.
 
S

Steve McLellan

Hi,

I'm using vcclr.h without any probs. I'm also compiling Boost under a mixed
compilation without any problems.

The following should be OK, for example:

#pragma once
#include <vcclr.h>
#include <boost/shared_ptr.hpp>

namespace SomeNamespace
{
__gc class ManagedClass;
}

class UnmanagedClass
{
public:
gcroot<SomeNamespace::ManagedClass *> myManagedClassP;
boost::shared_ptr< int > myBoostP;
}

As for obscure compiling and linking errors, I've had a few but they've
generally been solvable. Hope this helps a bit, if it doesn't, try posting a
bit of example code that doesn't work.

Steve
 
T

Tommy Vercetti

Thank you for the reply! That code you posted doesn't compile with the
same error that I specified.

I already posted some really simple code:
#include "stdafx.h"
#include <vcclr.h>

The mere act of including <vcclr.h> causes compilation errors. This is
with all default settings; in my original post I listed step by step
instructions of creating a new project, etc.
 

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

Top