dotgnu-pnet
[Top][All Lists]
Advanced

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

[Pnet-developers] [bug #5436] compiler error: using const string in DllI


From: nobody
Subject: [Pnet-developers] [bug #5436] compiler error: using const string in DllImport
Date: Thu, 09 Oct 2003 00:40:51 -0400
User-agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)

=================== BUG #5436: LATEST MODIFICATIONS ==================
http://savannah.gnu.org/bugs/?func=detailbug&bug_id=5436&group_id=353

Changes by: Anonymous user        Date: Thu 10/09/2003 at 00:40

------------------ Additional Follow-up Comments ----------------------------
Please note that using XYZ.LibName (ie qualifying the class in which the const 
string is does work)



=================== BUG #5436: FULL BUG SNAPSHOT ===================


Submitted by: None                    Project: DotGNU Portable.NET          
Submitted on: Fri 09/19/2003 at 12:12
Category:  None                       Severity:  5 - Major                  
Bug Group:  None                      Resolution:  None                     
Assigned to:  None                    Status:  Open                         

Summary:  compiler error: using const string in DllImport

Original Submission:  Hello, 

I've noticed that you cannot pass a const string to DllImport for the 
libraryname.

<code>
public const string LibName="MyLib";
[DllImport(LibName)] public static extern void Foo();
[DllImport(LibName)] public static extern void Bar();
</code>

this does compile with dotNET but not with dotGNU

cscc error : 'LibName' is not declared in the current scope

The current workaround is that you must pass a literal string to each interop 
entry like this: 

<code>
[DllImport("MyLib")] public static extern void Foo();
[DllImport("MyLib")] public static extern void Bar();
</code>

Unless the compiler optimizes out the duplicates, this will be extremely 
inefficient of memory.  Also, the potential for typing/copying errors 
increases.  If the library name ever changes, you'll need a good search/replace 
function.

Cheers, 

Oscar

Follow-up Comments
*******************

-------------------------------------------------------
Date: Thu 10/09/2003 at 00:40       By: None
Please note that using XYZ.LibName (ie qualifying the class in which the const 
string is does work)


CC list is empty


No files currently attached


For detailed info, follow this link:
http://savannah.gnu.org/bugs/?func=detailbug&bug_id=5436&group_id=353

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



reply via email to

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