static module functions

  • Thread starter Thread starter Lee Crabtree
  • Start date Start date
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
 
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
 
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"
 
Back
Top