public static void cppOutputSystemHeaderFile() {
    { SystemDefinition system = ((SystemDefinition)(Stella.$CURRENTSYSTEMDEFINITION$.get()));
      String systemname = system.name;
      String headeroutputfile = Stella.makeFileName(Stella.cppYieldSystemHeaderFileName(systemname), Stella.KWD_CPP_HEADER, true);

      { OutputFileStream headeroutputstream = null;

        try {
          headeroutputstream = Stella.openOutputFile(headeroutputfile, Stella.NIL);
          { Object old$CurrentStream$000 = Stella.$CURRENT_STREAM$.get();
            Object old$Module$000 = Stella.$MODULE$.get();
            Object old$CppCurrentUnitModule$000 = Stella.$CPP_CURRENT_UNIT_MODULE$.get();

            try {
              Native.setSpecial(Stella.$CURRENT_STREAM$, headeroutputstream);
              Native.setSpecial(Stella.$MODULE$, SystemDefinition.getCardinalModule(((SystemDefinition)(Stella.$CURRENTSYSTEMDEFINITION$.get()))));
              Native.setSpecial(Stella.$CPP_CURRENT_UNIT_MODULE$, null);
              {
                ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("// " + Stella.fileNameWithoutDirectory(headeroutputfile));
                ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println();
              }
;
              {
                ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("#ifndef " + Stella.cppYieldSystemHeaderFileGuard(systemname));
                ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("#define " + Stella.cppYieldSystemHeaderFileGuard(systemname));
                ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println();
              }
;
              if (system.requiredSystems != null) {
                ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("// Required systems:");
                { StringWrapper reqsys = null;
                  Cons iter000 = system.requiredSystems;

                  for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
                    reqsys = ((StringWrapper)(iter000.value));
                    Stella.cppOutputImportDeclarations(reqsys.wrapperValue);
                  }
                }
              }
              ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("// System-wide forward declarations:");
              { Stella_Object module = null;
                Cons iter001 = Cons.cons(((Module)(Stella.$MODULE$.get())), SystemDefinition.collectDefinedModulesFromSystemFile(system).remove(((Module)(Stella.$MODULE$.get()))));

                for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
                  module = iter001.value;
                  { Module currentnamespacemodule = null;

                    { Stella_Class renamed_Class = null;
                      Iterator iter002 = Module.allClasses(((Module)(module)), true);

                      while (iter002.nextP()) {
                        renamed_Class = ((Stella_Class)(iter002.value));
                        if (Stella_Class.createNativeClassP(renamed_Class)) {
                          Native.setSpecial(Stella.$CPP_CURRENT_UNIT_MODULE$, renamed_Class.homeModule());
                          if (currentnamespacemodule == null) {
                            ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println();
                          }
                          Module.cppOutputNamespaceChange(currentnamespacemodule, ((Module)(Stella.$CPP_CURRENT_UNIT_MODULE$.get())));
                          currentnamespacemodule = ((Module)(Stella.$CPP_CURRENT_UNIT_MODULE$.get()));
                          ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("class " + GeneralizedSymbol.cppTranslateClassName(renamed_Class.classType).wrapperValue + ";");
                        }
                      }
                    }
                    if (currentnamespacemodule != null) {
                      ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println();
                      Module.cppOutputNamespaceFooter(((Module)(Stella.$CPP_CURRENT_UNIT_MODULE$.get())));
                    }
                  }
                }
              }
              ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println();
              ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("// System components:");
              if (Stella.stringEqlP(systemname, "stella")) {
                Stella.cppOutputIncludeDirective(Stella.cppRelativizeHeaderFile(Stella_Object.makeFileNameFromRelativePath(Cons.list$(Cons.cons(StringWrapper.wrapString("cpp-lib"), Cons.cons(StringWrapper.wrapString("cpp-primal"), Cons.cons(Stella.NIL, Stella.NIL)))), Stella.KWD_CPP_HEADER), systemname), false);
              }
              { StringWrapper file = null;
                Cons iter003 = Cons.filesPlusSystemStartup(SystemDefinition.systemDefinitionSourceFiles(system));

                for (;!(iter003 == Stella.NIL); iter003 = iter003.rest) {
                  file = ((StringWrapper)(iter003.value));
                  Stella.cppOutputIncludeDirective(Stella.cppRelativizeHeaderFile(Stella.makeFileName(file.wrapperValue, Stella.KWD_CPP_HEADER, true), systemname), false);
                }
              }
              {
                ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println();
                ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("#endif");
              }
;

            } finally {
              Stella.$CPP_CURRENT_UNIT_MODULE$.set(old$CppCurrentUnitModule$000);
              Stella.$MODULE$.set(old$Module$000);
              Stella.$CURRENT_STREAM$.set(old$CurrentStream$000);
            }
          }

        } finally {
          if (headeroutputstream != null) {
            headeroutputstream.free();
          }
        }
      }
    }
  }