bugDotGNU Portable.NET - Bugs: bug #5436, compiler error: using const string...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #5436: compiler error: using const string in DllImport

Submitter:  None
Submitted:  Fri 19 Sep 2003 04:12:31 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Thu 27 Nov 2003 06:59:26 AM UTC, comment #3: 

Fix committed to CVS - 27 Nov 2003

Rhys Weatherley <rweather>
Group administrator
Thu 09 Oct 2003 06:19:37 AM UTC, comment #2: 

Read http://dotgnu.org/pipermail/pnet-developers/2003-May/000170.html

Which opens up a new can of worms. Does anyone have any idea what the priority of the stuff is ?.

type > namespace > member ?

Please verify and repost

Anonymous
Thu 09 Oct 2003 04:40:50 AM UTC, comment #1: 

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

Anonymous
Fri 19 Sep 2003 04:12:31 PM UTC, 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

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2003-11-27 rweather StatusNone Fixed
    Open/ClosedOpen Closed

Back to the top

Powered by Savane 3.13-02a9.
Corresponding source code