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.


3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.


That did the trick! Thanks for your help.

Leave a Comment

Please sign in to add a comment. Not a member? Join today