C++核心準(zhǔn)則邊譯邊學(xué)-I.26 如果想要不同編譯器都能適用的ABI,使用...

I.26: If you want a cross-compiler ABI, use a C-style subset(如果想要不同編譯器都能適用的ABI,使用C風(fēng)格規(guī)則子集)
Reason(原因)
Different compilers implement different binary layouts for classes, exception handling, function names, and other implementation details.
不同的編譯器會為類,異常處理,函數(shù)名和其他實現(xiàn)細節(jié)生成不同的二進制結(jié)構(gòu)。
Exception(例外)
Common ABIs are emerging on some platforms freeing you from the more draconian restrictions.
在某些平臺上出現(xiàn)的共通ABI可以將你從更加嚴格的限制中解放出來。
Note(注意)
If you use a single compiler, you can use full C++ in interfaces. That may require recompilation after an upgrade to a new compiler version.
如果使用單一編譯器,你可以在接口中使用完全的C++。這樣做可能會導(dǎo)致當(dāng)編譯器更新到新版本時,需要重新編譯。
譯者注:編譯器的版本變化也可能影響編譯結(jié)果的變化。
Enforcement(實施建議)
(Not enforceable) It is difficult to reliably identify where an interface forms part of an ABI.
(無法強制執(zhí)行)很難可靠地識別哪里的接口定義會成為ABI的一部分。
譯者注:ABI(Application Binary Interface):應(yīng)用程序二進制接口,描述了應(yīng)用程序和平臺之間,或者應(yīng)用的各個模塊之間接口的二進制定義。
譯者注:也就無法決定是否需要報警。
