Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>#import</code> directive is used with type libraries, often COM or .Net, not C++ source files. For complete details, see <a href="http://msdn.microsoft.com/en-us/library/8etzzkb6%28v=VS.100%29.aspx" rel="nofollow">the MSDN page</a>.</p> <p>In order to include C++ functions from another file, you typically want to use the <code>#include</code> directive (<a href="http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx" rel="nofollow">details</a>). This includes the code from the given file during compilation. Most often, you should include a header containing the function prototypes; it is possible to include code files, but not commonly needed or always safe.</p> <p>To do this, you should provide two files, a header and a source file, for your functions. The header will read something like:</p> <pre><code>#pragma once void Function(int arg); </code></pre> <p>and the source:</p> <pre><code>#include "functions.hpp" void Function(int arg) { ++arg; } </code></pre> <p>To use this in another file, you do:</p> <pre><code>#include "functions.hpp" void OtherFunction() { Function(2); } </code></pre> <p>You should also note that a header should typically be included only once. The MSVC-standard method of guaranteeing this is to add <code>#pragma once</code> to the beginning.</p> <p><strong>Edit:</strong> and to address the specific error you've posted, which applies to both <code>#import</code> and <code>#include</code>, the file you're attempting to include must be somewhere within the compiler's search path. In Visual Studio, you should add the necessary path to the project includes (this varies by version, but is typically under project properties -> compiler).</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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