diff --git a/src/idl_gen_general.cpp b/src/idl_gen_general.cpp
index 9a2132338eb404e45fec5ebd7207fa7e9af641fb..9bb411edfc23e76d4567b3e0d9a915b6bb665473 100644
--- a/src/idl_gen_general.cpp
+++ b/src/idl_gen_general.cpp
@@ -450,7 +450,7 @@ static void GenStructArgs(const LanguageParameters &lang,
       // don't clash, and to make it obvious these arguments are constructing
       // a nested struct, prefix the name with the struct name.
       GenStructArgs(lang, *field.value.type.struct_def, code_ptr,
-                    (field.value.type.struct_def->name + "_").c_str());
+                    (nameprefix + (field.name + "_")).c_str());
     } else {
       code += ", ";
       code += GenTypeForUser(lang,