<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Le 04/05/2022 à 11:10, Mahin Pandya a
      écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:SJ0PR06MB7830055D08E5530842792810EBC39@SJ0PR06MB7830.namprd06.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}span.EmailStyle21
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}div.WordSection1
        {page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal">Hi Eric, <o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Here is what we are trying to do:<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">- do you want that all places where WCHAR
          is used (meaning utf16) is replaced by utf32 encoding?<o:p></o:p></p>
        <p class="MsoNormal"><span
style="color:#385723;mso-style-textfill-fill-color:#385723;mso-style-textfill-fill-alpha:100.0%">Yes,
            all usage would be utf-32<o:p></o:p></span></p>
        <p class="MsoNormal">- do you want applications compiled in
          current WCHAR=2 bytes (including native windows applications)
          and applications with your WCHAR=4 bytes run in the same wine
          instance?<span
style="color:#385723;mso-style-textfill-fill-color:#385723;mso-style-textfill-fill-alpha:100.0%"><o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="color:#385723;mso-style-textfill-fill-color:#385723;mso-style-textfill-fill-alpha:100.0%">This
            would be WCHAR=4 bytes only. Native Windows Applications do
            not need to be supported.<o:p></o:p></span></p>
        <p class="MsoNormal">- cross compiling or simply compiling ?<o:p></o:p></p>
        <p class="MsoNormal"><span
style="color:#385723;mso-style-textfill-fill-color:#385723;mso-style-textfill-fill-alpha:100.0%">No
            cross-compilation. Currently planning to compile/build under
            Linux only.<o:p></o:p></span></p>
        <p class="MsoNormal">and perhaps to start with, why is current
          utf16 encoding not sufficient?<o:p></o:p></p>
        <p class="MsoNormal"><span
style="color:#385723;mso-style-textfill-fill-color:#385723;mso-style-textfill-fill-alpha:100.0%">We
            are trying to build Windows application using Wine Lib as
            native application (i.e. winelib
            <a href="https://wiki.winehq.org/Winelib"
              moz-do-not-send="true"><span
style="color:#385723;mso-style-textfill-fill-color:#385723;mso-style-textfill-fill-alpha:100.0%">https://wiki.winehq.org/Winelib</span></a>
            /
            <a href="https://wiki.winehq.org/Winelib_User%27s_Guide"
              moz-do-not-send="true"><span
style="color:#385723;mso-style-textfill-fill-color:#385723;mso-style-textfill-fill-alpha:100.0%">https://wiki.winehq.org/Winelib_User%27s_Guide</span></a>
            rather than wine to run Windows binaries). So that we can
            use other glibc functionality as well that use and expect
            native wchar_t sizes.</span></p>
      </div>
    </blockquote>
    <p>Hi Mahin, <br>
    </p>
    <p>as you may have noted (that's surely the case as you were looking
      for recompiling Wine with WCHAR=glibc.wchar_t), mixing headers,
      structures and APIs (with same name) between the windows and the
      unix environment might be tricky (to say the least)</p>
    <p>also the stack needed by both realms can be slightly different
      (exception unwinding in one example, there are others)</p>
    <p><br>
    </p>
    <p>moreover, depending on what your windows app does, and what the
      glibc (and perhaps other Unix ELF shared lib do), one of the
      safest option would be to:</p>
    <p>- compile your windows app as a PE file (either on Windows , or
      cross compiling under Linux) ; from using Winelib, it will reduce
      the errors in portability</p>
    <p>- isolate all you glibc calls into a dedicated DLL ; this DLL
      should use the unixlib infrastructure: it allows to create a DLL,
      visible and callable as any other DLL from your main .exe (or
      other DLLs if needed), but that DLL can have specific portions
      calling into ELF libraries (glibc being one of them)</p>
    <p>from your need, the DLL entry points would be utf16 (it's living
      in Windows world), but inside the DLL the transformation to or
      from utf32 (depending on what the flow of data is concerned)<br>
    </p>
    <p>this will clearly separate the two realms, and provide with
      limited effort the connection between the two</p>
    <p>see examples of such constructs in dlls/winepulse.drv, or
      nsysproxy.sys (there are others)</p>
    <p>there are some (slight) restrictions here:</p>
    <p>- if you intent to have 32 and 64 bit builds or wow64 use, then
      there are a couple of more things to do</p>
    <p>- calling back from the ELF part into the PE part is rather
      complex, so the idea is more like wrapping a call into an ELF
      library from the PE side<br>
    </p>
    <p><br>
    </p>
    <p>HTH<br>
    </p>
  </body>
</html>