Skip to content

Commit f8970d9

Browse files
committed
Handle circular includes
Fixes #150.
1 parent e5fa6b7 commit f8970d9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libclang/preprocessor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,11 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
10891089
else
10901090
xpath += *cpath;
10911091

1092+
// We strip all conditional defines and pragmas from the input, which includes the include
1093+
// guard. If the source includes a file, which includes itself again (for some reason), this
1094+
// leads to a duplicate include, as we no longer have an include guard. So we manually add one.
1095+
result.source += "#pragma once\n\n";
1096+
10921097
position p(ts::ref(result.source), preprocessed.file.c_str());
10931098
ts::flag in_string(false), in_char(false), first_line(true);
10941099
while (p)

0 commit comments

Comments
 (0)