Is there a way for GCC to produce a warning while linking libraries that contain classes with the same name? For example
Port.h
class Port {
Alternatively you could use a script utilizing nm to find candidates, e.g. something like:
import collections, subprocess, os, re, sys
def filt(s):
p = subprocess.Popen(['c++filt', s],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return p.communicate()[0].strip()
rx = re.compile('^[\\d\\w]+ T [\\w]+', re.MULTILINE)
sym = collections.defaultdict(set)
for file in sys.argv[1:]:
proc = subprocess.Popen(['nm', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for s in rx.findall(proc.communicate()[0]):
sym[s.split()[2]].add(file)
for s in filter(lambda x: len(sym[x])>1, sym):
print 'Duplicate "%s" in %s' % (filt(s), str(sym[s]))
foo:$ python dups.py *.a
Duplicate "Port::me()" in set(['Port.a', 'FakePort.a'])