title: Can't compile package containing DSUtils in XE2
body: <p>I am trying to compile a package containing DSUtils.pas (part of <a href="http://code.google.com/p/dspack/" rel="noreferrer">DSPack</a>) and it fails because it tries to compile wrong DirectShow9.pas unit - not the one from the DSPack but the one from the Delphi XE2 (Update 3) RTL.</p>
  
  <p>The problem can be repeated with a minimal package:</p>
  
  <pre><code>package Package1;
  
  {$R *.res}
  {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
  {$ALIGN 8}
  {$ASSERTIONS ON}
  {$BOOLEVAL OFF}
  {$DEBUGINFO ON}
  {$EXTENDEDSYNTAX ON}
  {$IMPORTEDDATA ON}
  {$IOCHECKS ON}
  {$LOCALSYMBOLS ON}
  {$LONGSTRINGS ON}
  {$OPENSTRINGS ON}
  {$OPTIMIZATION OFF}
  {$OVERFLOWCHECKS OFF}
  {$RANGECHECKS OFF}
  {$REFERENCEINFO ON}
  {$SAFEDIVIDE OFF}
  {$STACKFRAMES ON}
  {$TYPEDADDRESS OFF}
  {$VARSTRINGCHECKS ON}
  {$WRITEABLECONST OFF}
  {$MINENUMSIZE 1}
  {$IMAGEBASE $400000}
  {$DEFINE DEBUG}
  {$ENDIF IMPLICITBUILDING}
  {$IMPLICITBUILD ON}
  
  requires
    rtl;
  
  contains
    DSUtils in 'x:\common\pkg\dspack\src\DSPack\DSUtils.pas';
  
  end.
  </code></pre>
  
  <p>The error occurs in DSUtils line 1058 and the error is <code>Undeclared identifier: FrameRateCode</code>.</p>
  
  <pre><code>Result.FrameRateCode := (x and $00000003) shr 00;
  </code></pre>
  
  <p>Undeclared is 'FrameRateCode' - CtrlClick on the Result brings us to Winapi.DirectShow9 (in the RTL folder) which doesn't have this field declared.</p>
  
  <p>Interesting part - if I go to the DSUtils uses list, click on DirectShow9 and press Ctrl+Enter, the DSpack version of the unit will open (and this unit has FrameRateCode field defined). So Delphi knows where the unit is. It just tries to compile the package by using the wrong DirectShow9.</p>
  
  <p>Interesting tidbit: If I'm compiling a normal application (non-package) that uses DSUtils, everything works fine.</p>
  
  <p>What I've tried:</p>
  
  <ol>
  <li><p>Compiling DirectShow9 from the DSPack into its own package (actually I used DirectX9 package from DSPack which contains all files from the DirectX9 folder) and adding it to the 'requires' list. Doesn't work.</p></li>
  <li><p>Adding the folder with DirectShow9 file (from DSPack) to the beginning of the system path and rebooting. Doesn't work.</p></li>
  <li><p>Adding the folder with DirectShow9 file to the beginning of the library path. Doesn't work.</p></li>
  <li><p>Adding the DirectShow9 unit to the package with the explicit path. Doesn't work.</p></li>
  <li><p>Copying the DirectX9*.pas into the DSPack folder so that the DirectShow9 unit would be in the same folder as the DSUtils unit. Doesn't work.</p></li>
  </ol>
  
  <p>I see three possible workarounds, but I'm not happy with any of them.</p>
  
  <ol>
  <li><p>I can comment out the problematic code. Luckily, it is only this one line, everything else compiles with Delphi's DirectShow9.</p></li>
  <li><p>I can rename DirectShow9 from DSPack but then I may have to fix the 'uses' part in different application.</p></li>
  <li><p>I can turn off automatic prefixing with 'Winapi.' but that will cause me lots of additional work editing thousands and thousands files.</p></li>
  </ol>
  
  <p>What I would really like to see is getting XE2 to use the right source file. </p>