[PCH] Moving sources that use 'pragma once' to another directory causes redefinition errors.
| Bugzilla Link | 27801 |
| Version | trunk |
| OS | Windows NT |
Extended Description
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 (http://llvm.org/git/clang.git 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;}
$ mkdir sub_dir $ cp f.h header.h header.h.pch g.cpp sub_dir $ clang++ -c g.cpp -include-pch header.h.pch
Forgot to insert the change of directory command, should be: $ mkdir sub_dir $ cp f.h header.h header.h.pch g.cpp sub_dir $ cd sub_dir $ clang++ -c g.cpp -include-pch header.h.pch