dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] Conts && DllImport || What am I doing wrong?


From: jscottb
Subject: [Pnet-developers] Conts && DllImport || What am I doing wrong?
Date: Tue, 14 Oct 2003 08:21:00 -0500 (EST)

I am having a problem getting a const and DllImport to work together.  If
I have:

using System;
using System.Runtime.InteropServices;

namespace Test_it {
   public unsafe class Test {
      #if UNIX_SYSTEM
          internal const String DLLNAME = "libc.so.6";
      #endif

      #if MSWINDOWS_SYSTEM
         internal String DLLNAME = "mscrt.dll";
      #endif

      [DllImport(DLLNAME)]
      extern public static int getpid ( );

      public static void Main (string[] args)
      {
         Console.WriteLine (DLLNAME);
      }
   }
}

I compile it with:
cscc -DUNIX_SYSTEM -funsafe testconst.cs

And get:
testconst.cs:14: `DLLNAME' is not declared in the current scope
testconst.cs:14: constant value required

Now if I comment the DllImport line out, it works fine and can ilrun the
a.out produced and see the correct constant printed.

thanks,
scott

NOTE:  I just picked an arbitrary function here for test, not really
caring if it's in the MS crt.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]