static module functions

L

Lee Crabtree

I'm not sure what the term is, but is it possible in C++/CLI to create a
function not in a class that would then be visible to other .NET
languages? Something like:

namespace Blah
{
public ref class Thing
{
};

static void OhNoesImNotInAClass(int omfgwtfbbq);
}

Lee Crabtree
 
C

Carl Daniel [VC++ MVP]

Lee Crabtree said:
I'm not sure what the term is, but is it possible in C++/CLI to create a
function not in a class that would then be visible to other .NET
languages? Something like:

namespace Blah
{
public ref class Thing
{
};

static void OhNoesImNotInAClass(int omfgwtfbbq);
}

No, it's not. While (I believe!) the CLR does support free functions at a
very low level, they wouldn't be visible to any other language (and I'm not
sure if C++/CLI would compile the code anyway). Stick to functions that are
class members.

-cd
 
B

Bruno van Dooren [MVP VC++]

No, it's not. While (I believe!) the CLR does support free functions at
a very low level, they wouldn't be visible to any other language (and I'm
not sure if C++/CLI would compile the code anyway). Stick to functions
that are class members.

If I recall correctly, someone had this problem a couple of months ago,
where C++ compiled and used a free variable without a problem. C# couldn't
use it because it has no concept of things existing outside of classes.
He tried to export constants.
The solution was to create a class named CONST with const data members.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 

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