@@ -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
@@ -1871,8 +1874,7 @@ void CodeGenerator::generateExternalPackageStubs(std::ofstream &out,
18711874 auto *iface_ptr = package->get_interface (iface_name);
18721875 if (!iface_ptr)
18731876 {
1874- out << " // Interface not found: " << iface_name << " \n " ;
1875- continue ;
1877+ throw std::runtime_error (" Interface '" + iface_name + " ' not found in package '" + package_spec + " '" );
18761878 }
18771879
18781880 out << " namespace " << sanitize_identifier (iface_name) << " {\n " ;
0 commit comments