cyb70289 commented on code in PR #33847:
URL: https://github.com/apache/arrow/pull/33847#discussion_r1087404291
##########
cpp/src/arrow/type.h:
##########
@@ -288,31 +288,46 @@ std::shared_ptr<DataType> GetPhysicalType(const
std::shared_ptr<DataType>& type)
class ARROW_EXPORT FixedWidthType : public DataType {
public:
using DataType::DataType;
+ // This is only for preventing defining this class in each
+ // translation unit to avoid one-definition-rule violation.
+ ~FixedWidthType() override;
Review Comment:
> When a class has no non-pure, non-inline, virtual functions, there is no
key function, and the compiler is forced to emit the vtable in every
translation unit that references the class. In this case, it is emitted in a
COMDAT section, which allows the linker to eliminate all duplicate copies. This
is still wasteful in terms of object file size and link time, so it’s always
advisable to ensure there is at least one eligible function that can serve as
the key function.
Does it mean if a class has virtual functions, it's recommended that at
least one of them should be in `.cc`?
I find it hard to understand `a class has no non-pure, non-inline, virtual
functions`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]