Requirement for duplicate TYPE declaration

Started by David J Walker, August 29, 2005, 06:26:39 PM

Previous topic - Next topic

David J Walker

The following code resides in a module:
..........
Type ZIP_Desc_Type
   FilePath      As String * %MAX_PATH
   FileName      As String * %MAX_PATH
   FileDate      As Dword
   FileInfo       As unz_file_info_s
End Type
'
Function RestoreFiles (ZipName As String, SortFlag As Long) As Long
 
   Local DescArr() As ZIP_Desc_Type
   Local Zipheaders() As unz_file_info_s
.........

The declaration for unz_file_info_s is in another module.

Unless I put a copy of it in the first module, the line

FileInfo       As unz_file_info_s

gives an error 524 Undefined Type.

However, without the type declaration for ZIP_Desc_Type,

   Local Zipheaders() As unz_file_info_s

compiles OK without a second copy of the declaration for unz_file_info_s.

Any ideas?

TechSupport

This is another reason why I wish PowerBASIC allowed forward referencing. I attempt to simulate forward referencing in FireFly by collecting all of the TYPE definitions during the code generation stage. If I were to bet, I would say that the order in which the modules were processed has resulted in the unz_file_info_s definition appearing after the ZIP_Desc_Type definition (this would be in your _DECLARES.INC generated file.

How to fix it? hmmm... maybe try placing all of your TYPES into a dedicated module (e.g. AllTYPES.inc) and include that in your project ??? Other than that, I assume that you will have to do the hack of placing a duplicate copy of the unz_file_info_s TYPE in your first module.  :(

David J Walker

Thanks Paul, that was quick!

It's odd that it only it only seems to object to it in the type declaration, not in the line just below where it DIMs Zipheaders.