You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Brian McFarland (JIRA)" <ji...@apache.org> on 2009/11/09 23:45:52 UTC

[jira] Commented: (AMQCPP-253) Problems with compiler aCC on HPUX

    [ https://issues.apache.org/activemq/browse/AMQCPP-253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=55247#action_55247 ] 

Brian McFarland commented on AMQCPP-253:
----------------------------------------

Timothy & Wolfgang:

The problem I'm having with Pointer.h is that HP-UX defines NULL as a long, not a void *.  So when you do something like this:

Pointer<SomeType> p;
if( p != NULL )
{
    ....
}

you get an error about template deduction failing to find a match for operator!= for comparing Pointer<SomeType> to long.

The fix Wolfgang proposed was to use operator bool.  Operator bool will convert both NULL and the Pointer instance to a bool.  That works great for the case above, but causes problems for something like this:

Pointer<SomeType> p1, p2;
if( p1 == p2 )
{
   ...
}

The compiler might end up casting both Pointers to bool, and if both pointers are either null or non-null, then "==" results in true, which is not the desired result.

A safer option is to use operator void * as follows:
operator void * const {
    return (void *) this->value;
}

It acheives the same effect, because Pointer and NULL will both be cast to void *, but since Pointer the pointer still has a meaningful value, it no longer causes problems with Pointer to Pointer comparison.

Wolfgang:   I'm assuming by "HP's native compiler", you mean aCC?  If so, which version & what version of HP-UX?



> Problems with compiler aCC on HPUX
> ----------------------------------
>
>                 Key: AMQCPP-253
>                 URL: https://issues.apache.org/activemq/browse/AMQCPP-253
>             Project: ActiveMQ C++ Client
>          Issue Type: Improvement
>    Affects Versions: 3.0
>         Environment: HP-UX gemma1 B.11.23 U 9000/800
> aCC: HP ANSI C++ B3910B A.03.77
>            Reporter: Wolfgang.Klein
>            Assignee: Timothy Bish
>            Priority: Minor
>             Fix For: 3.1
>
>         Attachments: amq_cpp_30.tar
>
>
> compile errors with native HP compiler

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.