COMMON blocks

COMMON blocks

I am using common blocks in a single include file, then using this include file in each subroutine. I have 5 common blocks in this file, and all but one read fine. For some reason, one of them keeps giving me the error:

GetData.obj : error LNK2005: _INFO already defined in Readzip.obj
WriteData.obj : error LNK2005: _INFO already defined in Readzip.obj
WriteHeader.obj : error LNK2005: _INFO already defined in Readzip.obj
Debug/ReadWind.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

Where GetData,WriteData,WriteHeader are subroutines called by another subroutine, Readzip. The common block is named "info". Why is this happening for this block, but not the other common blocks?

Also - any suggestions on better methods to share data between subroutines this way? I don't particularly like common blocks, but I also don't want to pass these variables as arguments.

Thanks
michele

3 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

I suspect you are initializing some data within this common block. You can legally only do this in a BLOCK DATA program unit, or do it at runtime. That should eliminate your link errors.

If you want a "cleaner" method of sharing data, i.e. avoiding global variables, changing your common block to a derived type and passing the resulting single variable is my choice.

James

That did the trick! Thanks for your help.

Melden Sie sich an, um einen Kommentar zu hinterlassen.