- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
c:\\ivf\\bugs>type test.f90
program test
external scale
call scale
end
subroutine scale
write(*,*) 'hello'
end
c:\\ivf\\bugs>ifort test.f90
Intel Visual Fortran Intel 64 Compiler Professional for applications ...
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
Microsoft Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
-out:test.exe
-subsystem:console
test.obj
LIBCMT.lib(_filter_util_.obj) : error LNK2005: SCALE already defined in test.obj
test.exe : fatal error LNK1169: one or more multiply defined symbols found
The problem is my "scale" routine name conflicts with a 64-bit Microsoft library symbol. Intel support says basically its not a problem with their compiler and I should just rename the routine (which I did as a workaround). I thought that "name-mangling" was supposed to avoid this EVER happening. Is this technically a violation of Fortran standards and it is something they should fix?
Al Greynolds
www.ruda-cardinal.com
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have some control over name mangling through compiler and linker options. You can also tell the linker to ignore all but the first-seen instance of any symbol (/FORCE:MULTIPLE). If you find yourself using some options frequently, you can put them in the configuration file for convenience. But don't, please, force those preferences on everyone. I, for one, would want to know about name clashes so that I can take appropriate steps to resolve them.
-----------------------
I think that we can credit that infrequency to the ubiquitous use of shared libraries (.DLL on Win, OS2; .so in Unix/Linux; .exe on VMS). Of the many symbols in the source code used to build such a library, only a small fraction are "exported". The rest are all resolved and replaced by addresses when the shared library is built, and these symbols (the majority) are removed from possible future clashes with user symbols.
You could exploit this property of shared libraries. In particular, if all the routines that use SCALE and the routine that implements SCALE were put into a DLL, and SCALE was not exported, the name clash that prompted this thread would disappear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Al
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let me say a couple of words, (as a US-based first-line support engineer :-) ), in my colleague's defense.
Intel has customers spread worldwide, and therefore support staff spread worldwide as well.On the whole,support engineers tend to take issues submitted within or just before the workday of their own time zone, but there are plenty of exceptions.
In this case, the support engineer consulted a very experienced Fortran developer. As pointed out above, it's impossible to foresee the name conflicts that might arise between any arbitrary user symbol and a third party library. In this case, the symbol was introduced by Microsoft between one Visual Studio version and the next. (I would agree, that it seems like a symbol with a high risk of conflict). The suggestions of changing the subroutine name, or of redefining the symbol with a directive, seem likesensible, simpleones.
The internal run-time library symbols have names that make similar clashes unlikely. So the Fortran intrinsic SCALE does not cause a problem, for example. Putting an elaborate prefix on every user symbol doesn't seem very desirable. I think it's a reasonable question, why the trailing underscore that is used to distinguish Fortran symbols on IA-32 is not used by default on Intel64. (Al's issue does not arise on IA-32). If you wish, you can change this default with /assume:underscore, after which your program works.I don't know ifthis might cause other compatibility problems in a large program.
As you can imagine, changing sucha default at this point would break very many user programs, and would not be realistic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I added a couple of paragraphs to #1 with a suggestion for alleviating name clashes without your needing to resort to name decoration or renaming your routines.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm told that it was Microsoft who changed the convention by removing the leading (not trailing) underscore for external references in Intel64 compared to IA-32. So Intel Fortran just copies that. /assume:underscore adds a trailing underscore, which is just one way of resolving the ambiguity.
Fortran symbols are by default converted to upper case, whereas C symbols are usually lower case or contain lower case (but a convention, not a rule). This helps avoid clashes.SCALE from MSVCRTis something of an exception in being upper case.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page