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

Submitted by:  None
Submitted on:  Fri 19 Sep 2003 04:12:31 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned 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>
Project 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

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 27 Nov 2003 06:59:26 AM UTCrweatherStatusNone=>Fixed
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup1