C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Extensible vtables -- Ensuring ABI isn't broken

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Sat, 17 Feb 2024 19:37:26 +0100
Il 17/02/24 18:47, Frederick Virchanza Gotham via Std-Proposals ha scritto:
>
> So then you can ensure at compile-time that you haven't broken the ABI,
> as follows:
>
> #include <type_traits> // is_abi_compatible
>
> class IDeviceOld {
> public:
> virtual char const *GetName(void) = 0;
> virtual unsigned GetType(void) = 0;
> };
>
> class IDeviceNew {
> public:
> virtual char const *GetName(void) = 0;
> virtual unsigned GetType(void) = 0;
> virtual void *GetInputBuffer(void) = 0;
> virtual void *GetOutputBuffer(void) = 0;
> };
>
> static_assert( std::is_abi_compatible_v<IDeviceOld,IDeviceNew> );
>
> typedef IDeviceNew IDevice;

If you need to rename IDevice to IDeviceOld you've already broken ABI.
What am I missing?

-- 
Giuseppe D'Angelo

Received on 2024-02-17 18:37:30