Ticket #1219 (closed wish: fixed)

Opened 2 years ago

Last modified 2 years ago

Fix the C++ code so it compiles with clang compiler.

Reported by: ales Owned by: miha
Milestone: Future Component: library
Severity: minor Keywords:
Cc: janez Blocking:
Blocked By:

Description


Attachments

clang.patch Download (41.0 KB) - added by ales 2 years ago.

Change History

Changed 2 years ago by ales

comment:1 Changed 2 years ago by ales

  • Cc janez added
  • Status changed from new to assigned
  • Owner changed from ales to miha

Compiles with 'clang.patch' and CPPFLAGS='-Wno-address-of-temporary' on ubuntu 11.10 with clang 2.9.

Miha can you check if it also compiles on Mountain Lion?

comment:2 Changed 2 years ago by miha

Still fails on OS X 10.8, Apple clang version 4.0:

source/orange/callback.cpp:136:19: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PFilter fil = PyOrange_AsFilter(result);

source/orange/px/externs.px:540:62: note: expanded from macro 'PyOrange_AsFilter' #define PyOrange_AsFilter(op) (*(GCPtr< TFilter > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:291:24: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PClassifier clsf = PyOrange_AsClassifier(res);

~

source/orange/px/externs.px:108:70: note: expanded from macro 'PyOrange_AsClassifier' #define PyOrange_AsClassifier(op) (*(GCPtr< TClassifier > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:336:21: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

attribute = PyOrange_AsVariable(PyTuple_GET_ITEM(res, 1));

source/orange/px/externs.px:1534:66: note: expanded from macro 'PyOrange_AsVariable' #define PyOrange_AsVariable(op) (*(GCPtr< TVariable > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:375:30: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PDistribution dist = PyOrange_AsDistribution(result);

source/orange/px/externs.px:308:74: note: expanded from macro 'PyOrange_AsDistribution' #define PyOrange_AsDistribution(op) (*(GCPtr< TDistribution > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:463:28: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

descriptions = PyOrange_AsStringList(pydesc);

source/orange/px/externs.px:1292:70: note: expanded from macro 'PyOrange_AsStringList' #define PyOrange_AsStringList(op) (*(GCPtr< TStringList > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:561:19: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

newnode = PyOrange_AsTreeNode(result);

source/orange/px/externs.px:1436:66: note: expanded from macro 'PyOrange_AsTreeNode' #define PyOrange_AsTreeNode(op) (*(GCPtr< TTreeNode > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:597:20: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PImputer imp = PyOrange_AsImputer(res);

source/orange/px/externs.px:720:64: note: expanded from macro 'PyOrange_AsImputer' #define PyOrange_AsImputer(op) (*(GCPtr< TImputer > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:655:19: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PEVDist res = PyOrange_AsEVDist(result);

source/orange/px/externs.px:374:62: note: expanded from macro 'PyOrange_AsEVDist' #define PyOrange_AsEVDist(op) (*(GCPtr< TEVDist > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:759:17: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PRule res = PyOrange_AsRule(result);

source/orange/px/externs.px:1104:58: note: expanded from macro 'PyOrange_AsRule' #define PyOrange_AsRule(op) (*(GCPtr< TRule > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:780:21: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PRuleList res = PyOrange_AsRuleList(result);

source/orange/px/externs.px:1204:66: note: expanded from macro 'PyOrange_AsRuleList' #define PyOrange_AsRuleList(op) (*(GCPtr< TRuleList > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:804:17: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PRule res = PyOrange_AsRuleList(result);

source/orange/px/externs.px:1204:66: note: expanded from macro 'PyOrange_AsRuleList' #define PyOrange_AsRuleList(op) (*(GCPtr< TRuleList > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:846:13: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

rules = PyOrange_AsRuleList(result);

source/orange/px/externs.px:1204:66: note: expanded from macro 'PyOrange_AsRuleList' #define PyOrange_AsRuleList(op) (*(GCPtr< TRuleList > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:871:27: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PRuleClassifier res = PyOrange_AsRuleClassifier(result);

source/orange/px/externs.px:1144:78: note: expanded from macro 'PyOrange_AsRuleClassifier' #define PyOrange_AsRuleClassifier(op) (*(GCPtr< TRuleClassifier > *)(void *)(&PyOrange_AS_Orange(op)))

source/orange/callback.cpp:892:29: error: taking the address of a temporary object of type 'GCPtr<TOrange>'

[-Waddress-of-temporary]

PExamplesDistance res = PyOrange_AsExamplesDistance(result);

source/orange/px/externs.px:452:82: note: expanded from macro 'PyOrange_AsExamplesDistance' #define PyOrange_AsExamplesDistance(op) (*(GCPtr< TExamplesDistance > *)(void *)(&PyOrange_AS_Orange(op)))

14 errors generated.

comment:3 Changed 2 years ago by miha

It works, however, with CPPFLAGS="-Wno-address-of-temporary".

comment:4 Changed 2 years ago by miha

  • Status changed from assigned to closed
  • Resolution set to fixed

comment:5 Changed 2 years ago by Ales Erjavec <ales.erjavec@…>

In [2bb772691bd8211fcdda4dd38d4020a64d558e88/orange]:

Fixes for clang compiler support.

Added 'TOrangeVector::classDescription()' specialization to
'DEFINE_TOrangeVector_classDescription' macro and removed its default implementation
in the template class (static 'st_classDescription' member must be initialized/specialized before
its use).

A similar problem arises in the included '.ppp' files where st_classDescription is used. So I
moved all '.ppp. includes after the "DEFINE_*"s.

Removed unnecessary/duplicate VWRAPPER/WRAPPER uses.

Added 'this->...' qualifier in template classes (that inherit a from a template class) for
accessing base class methods, otherwise clang does not find them (as per C++ standard).

Moved the TVarList and TAttributed*List definitions/implementations from 'orvector' to 'vars'.
Fixed includes in other files using the two headers accordingly.

Fixed some casts to int with more appropriate casts to size_t/uintptr_t.

Added explicit casts of constants to template class in include/stat.hpp
statistics functions.

(references #1219).

Note: See TracTickets for help on using tickets.