[Mono-devel-list] Callling convention for interop call-backs

Karl Waclawek karl at waclawek.net
Wed Jan 21 15:39:03 EST 2004

> > You have *my* vote.
> > Instead of just supporting cdecl, why not add an attribute that
> > allows to specify any of the calling conventions for delegates?
> We can certainly use MCS for experimentation to get this going.
> If there are people interested in this, please cook up a few approaches,
> we can try them out, and submit to ECMA.

Well, as far as implementation goes I can't say much - being new to C#
and not being a compiler writer. But for the hack described in several places,
I am using an attribute defined like this:

using System;
using System.Runtime.InteropServices;

[Serializable, AttributeUsage(AttributeTargets.Delegate)]
public sealed class CallConvAttribute: Attribute {

  private CallingConvention kind; 

  public CallConvAttribute(CallingConvention kind) {
    this.kind = kind;

  public CallingConvention Kind {
    get { return kind; }

And then insert the appropriate modopt line depending on what
"kind" of calling convention the attribute denotes.


More information about the Mono-devel-list mailing list