Having manually expanded the ftp_src and ftp_dst macros in
FileCopyFtp.cc to make the compiler errors more readable; building
lftp-3.7.5 with the vendor C++ compiler on HPUX, causes make to
halt with the following error:

aCC -DHAVE_CONFIG_H -I. -I../lib -I../lib -I../trio -AA -z +Ofltacc +Olit=all 
+Oentrysched +Odataprefetch +Onolimit -Dsocklen_t=int -c FileCopyFtp.cc -o 
FileCopyFtp.o
Error 19: "FileCopyFtp.cc", line 41 # Unexpected '>'.
      get->GetSession().Cast<Ftp>()->Close();
                                ^            
Error 185: "FileCopyFtp.cc", line 41 # Left side of '->' requires a pointer to
   class; type found was 'class Ftp'.
      get->GetSession().Cast<Ftp>()->Close();

Also, I noticed several instances of the following warning wherever
FileAccess.h was seen by the compiler:

Warning 749: "FileAccess.h", line 415 # The cast from 'const FileAccessRef *'
    to 'const SMTaskRef<Fish> *' is performed as a 'reinterpret_cast'. This
    operation is non-portable and potentially unsafe.
          { void(static_cast<T*>(this->ptr)); return *(const SMTaskRef<T>*)this
                                                      ^^^^^^^^^^^^^^^^^^^^^

By manually unrolling and splitting all the expansions of the ftp_src and
ftp_dst macros in FileCopyFtp.cc from (e.g.):

  ftp_src->Close();

into:

  const SMTaskRef<Ftp> &ftp_src = (const SMTaskRef<Ftp>&)(get->GetSession());
  ftp_src->Close();

and deleting the original macros, I now get a similar 'warning 749' as
is given for the Cast() definition FileAccess.h as quoted above:

Warning 749: "FileCopyFtp.cc", line 38 # The cast from 'const FileAccessRef &'
  to 'const SMTaskRef<Ftp> &' is performed as a 'reinterpret_cast'. This
  operation is non-portable and potentially unsafe.
    const SMTaskRef<Ftp> &ftp_src = (const SMTaskRef<Ftp>&)(get->GetSession());
                                    ^^^^^^^^^^^^^^^^^^^^^^^

I am not particularly fluent in C++, so my questions are:

  (i) Am I unrolling the macros correctly?
 (ii) Do the warnings imply HPUX aCC is generating incorrect code?
(iii) Is there a better way to fix this code portably so that the warnings
      are not triggered at all?

Cheers,
    Gary
-- 
Gary V. Vaughan ([EMAIL PROTECTED])

Reply via email to