I am currently evolving a new project out of an existing one (still retaining the existing one as a separate project)
In the process, some modules have been removed. Retained variables declared in these modules have been relocated into new modules.
In one of my subroutines I accidentally left the USE statement for one of the deleted modules (name of module was "site_variables").
When trying to compile this subroutine, I kept getting messages that "The same named entity from different modules and/or program units cannot be referenced. [xxx]" (xxx = the variable affected names).
Took a while to track down the problem
- repeated searches of the all source files in the new project found only a single declaration of the affected variables (in the correct new modules).
- The fact that I had a "USE site_variables" statement, but no "MODULE site_variables" in the project was not reported as a syntax error.
- Eventually tracked the problem down by removing the USE statements for the new modules that declared the affected variables. The doing a full project build, I got messages such as
"error LNK2019: unresolved external symbol SITE_VARIABLES_mp_SGY referenced in function _SCENARIO_PR" (SGY being one of the affected variables). Hence the clue that "SITE_VARIABLES" was the problem.
Of course, I had to fix all the other syntax problems before I got this far!
What puzzles me is:
### First: HOW does the compiler relate "SITE_VARIABLES" and "SGY" when the original module ("SITE_VARIABLES" - that did contain "SGY") had long since been deleted from the new project?
The module "SITE_VARIABLES" (with a declaration for the "affected variables") does still exist in the original project. BUT that is a completely separate project, with source files in a separate directory on the HD. The ONLY connection I can find is that both are shown as (separate) projects on the "Start Page".
Makes debugging difficult if the compiler is reporting "same named entity from different modules" errors due to declarations in totally unrelated projects (without giving any clue that this is the case).
### Secondly: Why does the "USE site_variables" statement not produce a syntax error, if there is no "MODULE site_variables" in the current project?