diff --git a/cpp2rust/compat/arpa/inet.h b/cpp2rust/compat/arpa/inet.h index 44e0c035..e1d7fc10 100644 --- a/cpp2rust/compat/arpa/inet.h +++ b/cpp2rust/compat/arpa/inet.h @@ -8,12 +8,12 @@ #undef htonl #undef htons -uint32_t __cpp2rust_ntohl(uint32_t x); -uint16_t __cpp2rust_ntohs(uint16_t x); -uint32_t __cpp2rust_htonl(uint32_t x); -uint16_t __cpp2rust_htons(uint16_t x); +uint32_t cpp2rust_ntohl(uint32_t x); +uint16_t cpp2rust_ntohs(uint16_t x); +uint32_t cpp2rust_htonl(uint32_t x); +uint16_t cpp2rust_htons(uint16_t x); -#define ntohl(x) __cpp2rust_ntohl(x) -#define ntohs(x) __cpp2rust_ntohs(x) -#define htonl(x) __cpp2rust_htonl(x) -#define htons(x) __cpp2rust_htons(x) +#define ntohl(x) cpp2rust_ntohl(x) +#define ntohs(x) cpp2rust_ntohs(x) +#define htonl(x) cpp2rust_htonl(x) +#define htons(x) cpp2rust_htons(x) diff --git a/cpp2rust/compat/assert.h b/cpp2rust/compat/assert.h index a06ef790..a4182183 100644 --- a/cpp2rust/compat/assert.h +++ b/cpp2rust/compat/assert.h @@ -9,6 +9,6 @@ #include #endif -void __cpp2rust_assert_fail(bool condition) __attribute__((noreturn)); +void cpp2rust_assert_fail(bool condition) __attribute__((noreturn)); -#define assert(expr) __cpp2rust_assert_fail(expr) +#define assert(expr) cpp2rust_assert_fail(expr) diff --git a/cpp2rust/compat/platform_flags.h b/cpp2rust/compat/platform_flags.h index 063449a3..09ceb590 100644 --- a/cpp2rust/compat/platform_flags.h +++ b/cpp2rust/compat/platform_flags.h @@ -6,7 +6,7 @@ #include #include -static inline std::vector getPlatformClangFlags() { +static inline std::vector getPlatformClangBeginFlags() { std::vector flags = { "-resource-dir=" CLANG_RESOURCE_DIR, "-I" COMPAT_INCLUDE_DIR, @@ -17,3 +17,9 @@ static inline std::vector getPlatformClangFlags() { #endif return flags; } + +static inline std::vector getPlatformClangEndFlags() { + return { + "-Wno-gnu-include-next", + }; +} diff --git a/cpp2rust/converter/translation_rule.cpp b/cpp2rust/converter/translation_rule.cpp index 34315f73..c57b2a47 100644 --- a/cpp2rust/converter/translation_rule.cpp +++ b/cpp2rust/converter/translation_rule.cpp @@ -846,8 +846,10 @@ TypeRule ParseTypeRuleJSON(const llvm::json::Object &obj) { void LoadSrc(ExprRules &exprs, TypeRules &types, const std::filesystem::path &src_path) { - clang::tooling::FixedCompilationDatabase compilations( - ".", getPlatformClangFlags()); + auto flags = getPlatformClangBeginFlags(); + auto end_flags = getPlatformClangEndFlags(); + flags.insert(flags.end(), end_flags.begin(), end_flags.end()); + clang::tooling::FixedCompilationDatabase compilations(".", flags); ActionFactory factory(exprs, types); clang::tooling::ClangTool tool(compilations, {src_path.string()}); tool.run(&factory); diff --git a/cpp2rust/cpp2rust_lib.cpp b/cpp2rust/cpp2rust_lib.cpp index 549e1619..23402bd6 100644 --- a/cpp2rust/cpp2rust_lib.cpp +++ b/cpp2rust/cpp2rust_lib.cpp @@ -15,9 +15,11 @@ std::string TranspileSrc(std::string_view cc_code, Model model, const std::vector &cxx_flags, const std::string &rules_dir, std::string_view filename) { - auto tool_args = getPlatformClangFlags(); + auto tool_args = getPlatformClangBeginFlags(); tool_args.push_back("-fparse-all-comments"); tool_args.insert(tool_args.end(), cxx_flags.begin(), cxx_flags.end()); + auto end_flags = getPlatformClangEndFlags(); + tool_args.insert(tool_args.end(), end_flags.begin(), end_flags.end()); std::string rs_code; clang::tooling::runToolOnCodeWithArgs( @@ -43,7 +45,10 @@ std::string TranspileDir(std::string_view build_dir, Model model, clang::tooling::ClangTool Tool(*compile_dbase, files); Tool.appendArgumentsAdjuster(clang::tooling::getInsertArgumentAdjuster( - getPlatformClangFlags(), clang::tooling::ArgumentInsertPosition::BEGIN)); + getPlatformClangBeginFlags(), + clang::tooling::ArgumentInsertPosition::BEGIN)); + Tool.appendArgumentsAdjuster(clang::tooling::getInsertArgumentAdjuster( + getPlatformClangEndFlags(), clang::tooling::ArgumentInsertPosition::END)); std::string rs_code; FrontendActionFactory factory(rs_code, model, rules_dir); diff --git a/rules/assert/src.cpp b/rules/assert/src.cpp index 0e80c09e..6aae00d7 100644 --- a/rules/assert/src.cpp +++ b/rules/assert/src.cpp @@ -4,5 +4,5 @@ #include void f1(bool condition) { - return __cpp2rust_assert_fail(condition); + return cpp2rust_assert_fail(condition); }