By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,364 Members | 1,716 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,364 IT Pros & Developers. It's quick & easy.

Forward declarations and #pragma managed/unmanaged

P: n/a
Greetings!

Going directly to the point:

myclass.h:
//--------------------------------------

#pragma managed

//Forward declaration
class AnotherClass;

#pragma unmanaged

class MyClass
{
public:
void func1(AnotherClass* ptr);
}

Will this '#pragma managed' before 'class AnotherClass' have any effect at
all on my native class? I know the forwad declaration only puts the symbol's
name under the symbols table, but I was wondering if, being defined under
'managed' setting, this symbol would have any thunking layers or anything
like that that would make it's access slower.

Thanks,

Fabro

Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Gustavo L. Fabro wrote:
Greetings!

Going directly to the point:

myclass.h:
//--------------------------------------

#pragma managed

//Forward declaration
class AnotherClass;

#pragma unmanaged

class MyClass
{
public:
void func1(AnotherClass* ptr);
}

Will this '#pragma managed' before 'class AnotherClass' have any
effect at all on my native class? I know the forwad declaration only
puts the symbol's name under the symbols table, but I was wondering
if, being defined under 'managed' setting, this symbol would have any
thunking layers or anything like that that would make it's access
slower.


Based on a very simply experiment, it doesn't appear to make any difference.
What matters is whether #pragma managed is in effect where the class
definition appears.

<code>
#pragma managed

//Forward declaration
class AnotherClass;

#pragma unmanaged

class MyClass
{
public:
void func1(AnotherClass* ptr) {}
};

#pragma unmanaged // 1

class AnotherClass
{
public:
void f() {}
};
</code>

If the line at //1 is #pragma unmanaged, the resulting .obj looks identical
to that produced if // 1 is deleted. It // 1 is #pragma managed,
AnotherClass::f() is emitted as managed code.

-cd
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.