https://llvm.org/bugs/show_bug.cgi?id=27801

            Bug ID: 27801
           Summary: [PCH] Moving sources that use 'pragma once' to another
                    directory causes redefinition errors.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: pierregoussea...@gmail.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

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;}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to