>In C/C++, this is how I'd have done this:
>  #define BUILD_TIME __TIME__

If you really can't live without __TIME__ and other C++ macros, here's a
brutal (and quite possibly not completely correct) way to do it.

Step 1: Create a managed C++ class (BuildInfo.cpp)

---cut here---

  #using <mscorlib.dll>
  using namespace System;

  namespace Foo
  {
    __value class BuildInfo
    {
      static const String* _buildDate;
      static BuildInfo() { _buildDate = __DATE__; } // or whatever other
macro
  public:
      static const String* Date() { return _buildDate; }
    };
  }

---cut here---

Step 2: Make a .NET module (BuildInfo.module) out of it

  cl /c /clr:noAssembly BuildInfo.cpp
  link /NOASSEMBLY /DLL /NOENTRY BuildInfo.obj nochkclr.obj

Step 3: Use the module in your C# application (BuildInfoTest.cs)

  csc BuildInfoTest.cs /addmodule:BuildInfo.netmodule

---cut here---

  using System;

  namespace Foo
  {
    class EntryPoint
    {
      [STAThread]
      static void Main(string[] args)
      {
        Console.WriteLine(Foo.BuildInfo.Date());
      }
    }
  }

---cut here---

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to