Re: Right way of passing unmanaged structures between managed and native code?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Vladimir Kouznetsov (vladimir.kouznetsov_at_ngrain.com)
Date: 03/31/04

  • Next message: jchiller: "visual studio compile rules"
    Date: Wed, 31 Mar 2004 12:38:27 -0800
    
    

    Thank you Ronald,

    I found the following phrase
    (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstecha
    rt/html/vbtchtroubleshootingnetinteroperability.asp "Troubleshooting .NET
    Interoperability"): "Because Visual Studio .NET optimizes the way data is
    stored, the unmanaged representation of the structure does not always match
    the managed representation". From that I concluded that either alignment or
    order of members or both can be different for managed and unmanaged code. If
    I'm misinterpreting that, that probably should be clarified. Otherwise if
    that is incorrect I'm happy to know that.

    thanks,
    v

    "Ronald Laeremans [MSFT]" <ronaldl@online.microsoft.com> wrote in message
    news:eFothx1FEHA.3064@tk2msftngp13.phx.gbl...
    > Hi Vladimir,
    >
    > Unmanaged types are guaranteed to have the same representation regardless
    of
    > whether they are compiled with or without the /clr switch. What
    > documentation or experiment makes you believe otherwise?
    >
    > Ronald Laeremans
    > Visual C++ team
    >
    > "Vladimir Kouznetsov" <vladimir.kouznetsov@ngrain.com> wrote in message
    > news:%23hbHnueFEHA.3032@TK2MSFTNGP09.phx.gbl...
    > > Hi group,
    > >
    > > It seems there are no guarantees that the same unmanaged structures have
    > the
    > > same binary representation for managed and native code. How do I use
    them
    > in
    > > mixed-code assemblies? Is there just some compiler magic behind curtains
    > > (IJW, some implicit marshalling, which can lead to a performance
    > > degradation) or the data are binary compatible in these scenarios or I
    > > perhaps should use attributes to explicitly specify the layout (which
    BTW
    > > may depend on compiler switches increasing complexity of maintenance)?
    > >
    > > thanks,
    > > v
    > >
    > >
    >
    >


  • Next message: jchiller: "visual studio compile rules"

    Relevant Pages

    • Re: INT defect: Please try this on 2007 for me
      ... that I have provided to back up my explanation. ... VALUEconverts A1 as Excel would do to ... the exact internal representation of 40000.846. ... ROUNDDOWN returns the binary representation of 40000.845, ...
      (microsoft.public.excel.worksheet.functions)
    • Re: scwewy answers that dont belong
      ... And it is not just that there might be no exact binary representation ... set of pairwise operands has the same binary magnitude, ... that might be a viable solution for you, ...
      (microsoft.public.excel.worksheet.functions)
    • Re: Singles to Doubles
      ... The internal i/o routines that parse the source file do the conversion from the external ASCII base 10 representation to the internal binary representation. ... When promoting from Single to Double, there is _NO_ information about what the trailing numerators are or should be for the powers of 2 from the 29th to the 53rd bit so, as someone else noted, lacking that information they're set to 0 as the most accurate value _ON AVERAGE_. ... What then looks like "garbage" in external representation is, in fact what the continuing fraction w/ all numerators zero is. ...
      (microsoft.public.vb.general.discussion)
    • Re: Cantor Confusion
      ... >>> They have no finite binary representation. ... then they can appear in a tree. ... his diagonal proof was about lists ...
      (sci.math)
    • Re: puzzle
      ... > languages all permit access to a binary representation" don't address ... Complexity theory deals with the properties of arbitrary algorithms. ...
      (comp.programming)