views:

5

answers:

0

What is the best way to avoid name clashes in SWIG generated functions?

I have two different C++ classes with partially identical function names. When I call such a function on an object, given both classes are loaded in the target language, it seems related to which library was loaded first, which function gets actually executed. It has nothing to do with the type of object that I created.

Problem seems especially prominent in ruby:

require 'Class1'
require 'Class2'

o1 = Class1.new # create object of Class 1, not class 2
o1.function          # executes 'function' from Class 1

o2 = Class2.new # create object of Class 2, not class 1
o2.function          # PROBLEM! executes also 'function' from Class 1

When I reverse the 'require' statements, the problem also reverses. Therefore, which function is actually executed, depends on the order of the 'requires'. I have searched the SWIG documentation but found no obvious answer. Perhaps the problem is due to the internal Ruby Handling of objects.

Thank you