- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That did the trick! Thanks for your help.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page