EricksonBrian

Hi all,

I started this thread in the General form but it turned into a language question so I'm asking over here.

I have a class defined as follows:

// PCSInit.h
#pragma once

#include <stdio.h>
#include "pcstypes.h"
#include "pcsshmem.h"
#include "rtdd.h"
#include "pcsproc.h"
#ifndef PCS_SUCCESS
#include "pcserr.h"
#endif

namespace BauerControls {
namespace PCSTools {

public ref class PCSInit sealed
{
private:
PCSInit(void);

public:
static long SetProcessName( char *ProcessName );
static long OpenRTDD(void);
static void UnInit( void );
~PCSInit( void );
static RTDD_HANDLES *ptrRTDD;

private:
static bool ProcessOK; //set TRUE by SetProcessName.

};
}} //Namespaces

I'd like to put the class in a DLL and export all the public symbols. Everything works great except the system ptrRTDD. the compiler complains that it can't access the private member. It's clearly not private. I get the same kind of error if the methods of the class return an non-standard type.

The conclusion that I've reached is that it's not possible to export an unmanaged type. So, what I've done it declare the ptrRTDD variable to be a void * and then cast it whenever I need to use it.

I'm hoping someone here can show me the error of my ways...

Thanks,

Brian



Re: Visual C++ Language Managed class and legacy C code

MikeSandberg

Hi Brian,

What you're probably looking for is make_public pragma. Refer to http://msdn2.microsoft.com/en-us/library/ms235607(VS.80).aspx.

Hope that helps.





Re: Visual C++ Language Managed class and legacy C code

EricksonBrian

Thanks!

One last question. How does an experienced programer get up to speed with .NET I've spent two days looking for this answer. I never stumbled across anthing about a make_public pragma (and never thought to look at pragma directives)

One obvious answer is to post here sooner...

Brian





Re: Visual C++ Language Managed class and legacy C code

MikeSandberg

I've found books to be a good starting point for .NET development. "Framework Design Guidelines" by Cwalina and Abrams is the de facto standard for how to .NET code should be written. "CLR via C#" by Jeffrey Richter is an excellent book about the CLR itself. Although both of these books use C# throughout, they should be useful to anyone using the CLR from any .NET language. For C++/CLI, I've found Marcus Heege's "Expert C++/CLI" to be pretty informative, but it doesn't cover introductory topics very much.

If books aren't your style a few of the VC team members write blogs and that are pretty good for C++/CLI info. And there's always the C++/CLI spec, of course. It's pretty dry reading, tho.