Strange problem with msvc in kdepimlibs/kcal

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Fri Jul 21 07:05:00 BST 2006


Hi,

I want to compile kdepimlibs with msvc (because kdebase needs it) and after some minor problems I now get a strange error in kcal. I've attached a small testcase to show the problem.

The output with gcc:

D - Recurrence::Observer::Observer()
G - Incidence::Incidence()
A - RecurrenceRule::Observer::Observer()
E - Recurrence::Recurrence()
F - void Recurrence::addObserver(Recurrence::Observer*)

and msvc:

A - RecurrenceRule::Observer::Observer
G - Incidence::Incidence
A - RecurrenceRule::Observer::Observer
E - Recurrence::Recurrence
F - Recurrence::addObserver

As you can see, different constructors are called.
In my understanding, both of them are correct. But I don't know what the c++ standard says about such an ambiguity.

Any ideas how this could be solved without renaming one of the classes? 

Christian
-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
-------------- next part --------------
#include <stdio.h>

#ifndef __GNUC__
# define __PRETTY_FUNCTION__ __FUNCTION__
#endif

class RecurrenceRule
{
   public:
	class Observer
    {
        public:
    		Observer() {fprintf(stderr, "A - %s\n", __PRETTY_FUNCTION__);}
	};
	RecurrenceRule(){fprintf(stderr, "B - %s\n", __PRETTY_FUNCTION__);}
	void addObserver(Observer *) {fprintf(stderr, "C - %s\n", __PRETTY_FUNCTION__);}
};


class Recurrence : public RecurrenceRule::Observer
{
   public:
	class Observer
    {
        public:
		Observer() {fprintf(stderr, "D - %s\n", __PRETTY_FUNCTION__);}
	};
	Recurrence() {fprintf(stderr, "E - %s\n", __PRETTY_FUNCTION__);}
	void addObserver(Observer *) {fprintf(stderr, "F - %s\n", __PRETTY_FUNCTION__);}
};

class Incidence : public Recurrence::Observer
{
	public:
		Incidence();
};

Incidence::Incidence() : Recurrence::Observer()
{
    fprintf(stderr, "G - %s\n", __PRETTY_FUNCTION__);
    Recurrence *myRec = new Recurrence();
    myRec->addObserver(NULL);
//	myRec->addObserver(this);       // doesn't work with msvc
}

int main(int argc, char**argv)
{
    Incidence *tmp = new Incidence();
    delete tmp;
    return 1;
}


More information about the kde-core-devel mailing list