Skip to content

Commit d3321d9

Browse files
committed
WIP
1 parent 0b9ebc6 commit d3321d9

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tools/wit-codegen/code_generator.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ void CodeGenerator::generateHeader(const std::vector<InterfaceInfo> &interfaces,
2121
throw std::runtime_error("Cannot create header file: " + filename);
2222
}
2323

24-
// Generate header guard
25-
std::string guard = "GENERATED_" + sanitize_identifier(filename) + "_HPP";
24+
// Generate header guard using just the filename (not full path)
25+
std::filesystem::path filepath(filename);
26+
std::string guard = "GENERATED_" + sanitize_identifier(filepath.filename().string()) + "_HPP";
2627
std::transform(guard.begin(), guard.end(), guard.begin(), ::toupper);
2728

2829
out << "#pragma once\n\n";
@@ -893,8 +894,10 @@ void CodeGenerator::generateWAMRHeader(const std::vector<InterfaceInfo> &interfa
893894
throw std::runtime_error("Cannot create WAMR header file: " + filename);
894895
}
895896

896-
// Header guard
897-
std::string guard = "GENERATED_WAMR_BINDINGS_HPP";
897+
// Header guard using just the filename (not full path)
898+
std::filesystem::path filepath(filename);
899+
std::string guard = "GENERATED_" + sanitize_identifier(filepath.filename().string()) + "_HPP";
900+
std::transform(guard.begin(), guard.end(), guard.begin(), ::toupper);
898901
out << "#ifndef " << guard << "\n";
899902
out << "#define " << guard << "\n\n";
900903

0 commit comments

Comments
 (0)