Browse Source

Generate extern typedefs earlier.

Brucey 4 years ago
parent
commit
2cca5424c2
1 changed files with 13 additions and 2 deletions
  1. 13 2
      ctranslator.bmx

+ 13 - 2
ctranslator.bmx

@@ -3842,10 +3842,12 @@ End Rem
 
 		Next
 	End Method
+	
+	Method EmitExternClassProtoTypedef( classDecl:TClassDecl )
+		Emit "typedef struct " + classDecl.ident + " " + classDecl.ident + ";"
+	End Method
 
 	Method EmitExternClassProto( classDecl:TClassDecl )
-
-		Emit "typedef struct " + classDecl.ident + " " + classDecl.ident + ";"
 		
 		' vtable
 		Emit "struct " + classDecl.ident  + "Vtbl {"
@@ -6000,6 +6002,15 @@ End Rem
 				End If
 			EndIf
 		Next
+		
+		' prototypes/header - typedefs
+		For Local cdecl:TClassDecl=EachIn app.Semanted()
+			If cdecl.declImported Continue
+			
+			If Not cdecl.IsStruct() And cdecl.IsExtern() Then
+				EmitExternClassProtoTypedef(cdecl)
+			End If
+		Next
 
 		'prototypes/header!
 		For Local decl:TDecl=EachIn app.Semanted()