+ if((c_mode & _MS) == 0)
+ return;
+
+ decl_modifiers_t modifiers = declaration->modifiers;
+
+ bool ds_shown = false;
+ const char *next = "(";
+
+ if (declaration->base.kind == ENTITY_VARIABLE) {
+ variable_t *variable = (variable_t*) declaration;
+ if (variable->alignment != 0
+ || variable->get_property_sym != NULL
+ || variable->put_property_sym != NULL) {
+ if (!ds_shown) {
+ fputs("__declspec", out);
+ ds_shown = true;
+ }
+
+ if(variable->alignment != 0) {
+ fputs(next, out); next = ", "; fprintf(out, "align(%u)", variable->alignment);
+ }
+ if(variable->get_property_sym != NULL
+ || variable->put_property_sym != NULL) {
+ char *comma = "";
+ fputs(next, out); next = ", "; fputs("property(", out);
+ if(variable->get_property_sym != NULL) {
+ fprintf(out, "get=%s", variable->get_property_sym->string);
+ comma = ", ";
+ }
+ if(variable->put_property_sym != NULL)
+ fprintf(out, "%sput=%s", comma, variable->put_property_sym->string);
+ fputc(')', out);
+ }
+ }
+ }
+
+ /* DM_FORCEINLINE handled outside. */
+ if ((modifiers & ~DM_FORCEINLINE) != 0) {
+ if (!ds_shown) {
+ fputs("__declspec", out);
+ ds_shown = true;
+ }
+ if(modifiers & DM_DLLIMPORT) {
+ fputs(next, out); next = ", "; fputs("dllimport", out);
+ }
+ if(modifiers & DM_DLLEXPORT) {
+ fputs(next, out); next = ", "; fputs("dllexport", out);
+ }
+ if(modifiers & DM_THREAD) {
+ fputs(next, out); next = ", "; fputs("thread", out);
+ }
+ if(modifiers & DM_NAKED) {
+ fputs(next, out); next = ", "; fputs("naked", out);
+ }
+ if(modifiers & DM_THREAD) {
+ fputs(next, out); next = ", "; fputs("thread", out);
+ }
+ if(modifiers & DM_SELECTANY) {
+ fputs(next, out); next = ", "; fputs("selectany", out);
+ }
+ if(modifiers & DM_NOTHROW) {
+ fputs(next, out); next = ", "; fputs("nothrow", out);
+ }
+ if(modifiers & DM_NORETURN) {
+ fputs(next, out); next = ", "; fputs("noreturn", out);
+ }
+ if(modifiers & DM_NOINLINE) {
+ fputs(next, out); next = ", "; fputs("noinline", out);
+ }
+ if (modifiers & DM_DEPRECATED) {
+ fputs(next, out); next = ", "; fputs("deprecated", out);
+ if(declaration->deprecated_string != NULL)
+ fprintf(out, "(\"%s\")",
+ declaration->deprecated_string);
+ }
+ if(modifiers & DM_RESTRICT) {
+ fputs(next, out); next = ", "; fputs("restrict", out);
+ }
+ if(modifiers & DM_NOALIAS) {
+ fputs(next, out); next = ", "; fputs("noalias", out);
+ }
+ }
+
+ if (ds_shown)
+ fputs(") ", out);
+}
+
+static void print_scope(const scope_t *scope)
+{
+ const entity_t *entity = scope->entities;
+ for ( ; entity != NULL; entity = entity->base.next) {
+ print_indent();
+ print_entity(entity);
+ fputs("\n", out);
+ }
+}
+
+static void print_namespace(const namespace_t *namespace)
+{
+ fputs("namespace ", out);
+ if (namespace->base.symbol != NULL) {
+ fputs(namespace->base.symbol->string, out);
+ fputc(' ', out);
+ }
+
+ fputs("{\n", out);
+ ++indent;
+
+ print_scope(&namespace->members);
+
+ --indent;
+ print_indent();
+ fputs("}\n", out);
+}
+
+/**
+ * Print a variable or function declaration
+ */
+void print_declaration(const entity_t *entity)
+{
+ assert(is_declaration(entity));
+ const declaration_t *declaration = &entity->declaration;
+