Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think this is a problem with CMake; I believe gcc will always find your "time.h" before the system one, regardless of whether you use quotes or brackets in the <code>#include</code> and regardless of the various options in <code>include_directories</code>. See the entries for <code>-I</code> and <code>-isystem</code> in the <a href="http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-isystem-930" rel="nofollow">gcc documentation</a></p> <p>The <code>AFTER</code> option of CMake's <code>include_directories</code> relates only to the order of the directories as listed in the gcc command, it doesn't relate to gcc's <code>-idirafter</code> flag.</p> <p>It's not a great plan to have your own files with identical names to system files, but if your hands are tied, you could avoid this issue without renaming time.h by qualifying the path for your own includes more fully, so rather than e.g.</p> <pre><code>CMakeLists.txt: include_directories(${PROJECT_SOURCE_DIR}/src) header file: #include &lt;time.h&gt; // we want but don't get system one #include "time.h" // we want and get own custom one </code></pre> <p>something more like</p> <pre><code>CMakeLists.txt: include_directories(${PROJECT_SOURCE_DIR}) header file: #include &lt;time.h&gt; // we want and get system one #include "src/time.h" // we want and get own custom one </code></pre> <p><br/> An alternative option would be to stick with your current <code>#include</code> setup (using angle brackets for the system time.h and quotes for your own) and not use <code>include_directories</code> at all in the CMakeLists.txt. Instead I think you could replace it with something like:</p> <pre><code>set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -iquote ${PROJECT_SOURCE_DIR}/src") </code></pre> <p>Using <code>-iquote</code> is probably a better option than <code>-idirafter</code> since the directory specified by <code>-idirafter</code> is (in this case incorrectly) treated as a system directory, and as such has warnings suppressed, etc.</p> <p>If you do go for this choice, it's probably worth commenting the CMakeLists.txt to explain why there is no <code>include_directories</code> to avoid future refactoring reverting back to use the more normal <code>include_directories</code> command.</p> <p>All in all, your best option if at all possible would be to rename your "time.h" file though.</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.
 

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