<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [PCH] Moving sources that use 'pragma once' to another directory causes redefinition errors."
href="https://llvm.org/bugs/show_bug.cgi?id=27801">27801</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[PCH] Moving sources that use 'pragma once' to another directory causes redefinition errors.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pierregousseau14@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>A redefinition error is emitted with the following sequence of commands. No
errors if using a header guard instead of #pragma once.
f.h:
#pragma once
int f() {return 0;}
header.h:
#include "f.h"
g.cpp:
#include "f.h"
int g() { return f();}
$ clang++ --version
clang version 3.9.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
fd7431291bd2bcd4ea3b768d5eff7098dd22266f)
$ clang++ -x c++-header header.h -o header.h.pch
$ mkdir sub_dir
$ cp f.h header.h header.h.pch g.cpp sub_dir
$ clang++ -c g.cpp -include-pch header.h.pch
In file included from g.cpp:1:
./f.h:6:5: error: redefinition of 'f'
int f() {return 0;}
^
/home/pierre/lab/f.h:6:5: note: previous definition is here
int f() {return 0;}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>