static module functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lee Crabtree

    static module functions

    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 OhNoesImNotInAC lass(int omfgwtfbbq);
    }

    Lee Crabtree
  • Carl Daniel [VC++ MVP]

    #2
    Re: static module functions

    "Lee Crabtree" <lcrabtree@gois i.comwrote in message
    news:uhG2QjyuGH A.1852@TK2MSFTN GP04.phx.gbl...
    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 OhNoesImNotInAC lass(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


    Comment

    • Bruno van Dooren [MVP VC++]

      #3
      Re: static module functions

      >>
      > static void OhNoesImNotInAC lass(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.
      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
      bruno_nos_pam_v an_dooren@hotma il.com
      Remove only "_nos_pam"


      Comment

      Working...