Note that there are some explanatory texts on larger screens.

plurals
  1. POUINT32 compiler version mismatch - Linking to legacy library
    primarykey
    data
    text
    <p>I am trying to link a DLL but I am constantly running into issues with <code>UINT32</code>.</p> <p>The library is compiled against the 4.1 version of the Visual Studio compiler. The interface for my component (which was 4.1 and I am now porting to 2012) is defined with many <code>UINT32</code>s in it. In VC4.1 <code>UINT32</code> is not defined by the compiler and so it was typedefed to <code>unsigned long</code> by the programmer, but from VC6 onwards <code>UINT32</code> is defined as <code>unsigned int</code>. This makes my life hard.</p> <p>My initial reaction was to try replacing all <code>UINT32</code> in the interface with <code>unsigned long</code> and recompiling. This works as the function signatures are the same. However an <code>unsigned long</code> in 2012 is 64 bits wide... not 32 bits. This is not a problem in most cases but I foresee possible problems with flag parameters and return types.</p> <p>What I am wondering is if I have missed a more obvious solution for this. I thought of defining a different type</p> <pre><code>typedef OAM_UINT32 unsigned long //in the library typedef OAM_UINT32 unsigned int // in my component </code></pre> <p>But then the problem is going to be the same as what I have already with my two definitions of UINT32... right?</p> <p>Any help would be much appreciated.</p> <p><strong>The Problem</strong></p> <p>Client code</p> <pre><code>#include &lt;oam_if.h&gt; .... UINT32 uuid = getSomeLocalUserId(); UINT32 dwOamRetVal = dwOamGetUserDetails( uuid ); // LINK ERROR: Symbol not found </code></pre> <p>oam_if.h</p> <pre><code>UINT32 dwOamGetUserDetails( UINT32 idOfUser ); </code></pre> <p>When the library (OAM) is compiled the UINT32 value is evaluated as an <code>unsigned long</code>. When the client component is compiled, UINT32 is evaluated as <code>unsigned int</code>. The linker complains because it has a symbol defined in the OAM library for <code>dwOamGetuserDetails</code> which rakes and returns an <code>unsigned long</code>, but the client is calling a function which according to it should take an <code>unsigned int</code>. </p> <p>So while their respective inputs are unsigned numbers both 32 bits long, the signature of the function is different and the linker complains.</p> <p>The only way I can see to fix it is to define everything as <code>unsigned long</code> directly. However then OAM will be using a 32 bit long number but the client will be using a 64 bit number!</p> <p><strong>Sample of Linker Error</strong></p> <blockquote> <p>error LNK2001: unresolved external symbol "public: virtual unsigned long __thiscall Message::getCallId(void)const " (?getCallId@Message@@UBEKXZ) oam.lib(OAM_SsRequest.obj)</p> </blockquote> <p>This is actually a callback from the library to the component, so in this case it is looking for a signature that matches UINT32 as defined by the libary (unsigned long) but the component is defining an unsigned int for its callback.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload