On Sat, May 01, 2010 at 11:39:00AM +0200, Christopher Zimmermann wrote:
> Hi,
> 
> the following piece of code compiles fine using g++ 4.2.4, but 
> fails using g++ 3.3.5 in the base system:
> 
> error: operands to ?: have different types
> 
> It is part of ptlib, which is the base library for opal, which in 
> turn is needed for ekiga, which I'm trying to port.
> 
> What is your suggestion? Can anyone think of a workaround for 
> this or should I just compile it using eg++ 4.2.4 ?
> 
> 
> Christopher
> 
> 
> #include<err.h>
> 
> #define WarnIfNULL(x) ((x) ? (x) : (warn("blub"),(x)))
> 
> class A
> {
>   protected:
>     int a;
> };
> 
> class B : A
> {
>   public:
>     void blub()
>     {
>          WarnIfNULL(A::a);
>     }
> };

Why do some C++ programmer still use macros where they're not needed ?
bunch of idiots, let them stay with C.

#include<err.h>

template<typename T>
inline T WarnIfNULL(T x)
{
        if (!x)
                warn("blub");
        return x;
}

class A
{
  protected:
    int a;
};

class B : A
{
  public:
    void blub()
    {
         WarnIfNULL(A::a);
    }
};

Reply via email to