我正在迁移旧C++代码的一些部分,最初使用CodeGear C++Builder®2009版本12.0.3170.16989编译
以下代码 - 更大版本的最小版本 - -34使用任何现代编译器输出.虽然,在原始平台中输出84:
char Key[4];    
Key[0] = 0x1F;
Key[1] = 0x01;
Key[2] = 0x8B;
Key[3] = 0x55;
for(int i = 0; i < 2; i++) {
    Key[i] = Key[2*i] ^ Key[2*i + 1];
}
std::cout << (int) Key[1] << std::endl;
for(int i = 0; i < 2; i++) {
    char a = Key[2*i];
    char b = Key[2*i + 1];
    char c = a ^ b;
    Key[i] = c;
}
此外,手动展开循环似乎适用于两个编译器: …
我最近开始将我的RAD Studio 2007项目升级到RAD Studio 2009.我注意到的一件事是看似简单的代码突然无法编译.
示例代码:
class CButtonPopupMenu
{
    // Snip
public:
    void Init( TButton* SrcButton )
    {
        SrcButton->OnClick = OnButtonClick;
    }
private:
    void __fastcall OnButtonClick( TObject* Sender )
    {
        // Do some button click stuff
    }
};
// Snip
TButton button = new TButton( this );
TBitBtn bitBtn = new TBitBtn( this );
CButtonPopupMenu popupButton = new CButtonPopupMenu( button );
CButtonPopupMenu popupBitBtn = new CButtonPopupMenu( bitBtn );
这一切都用于编译,但在2009年它失败了.看看2007年的继承链TBitBtn来源于TButton.因此,TButton该类共享任何按钮控件(即OnClick)上预期的事件.因此,我能够把我的TBitBtn班级视为一个TButton.
2007年继承链: …
Codegear RAD Studio 2009中是否需要"冗余包括警卫"?编译器是否足够聪明,可以自行处理?
例如,我可能在foo.h中有以下'include guard':
#ifndef fooH
#define fooH
// ... declaration here
#endif
以及use_foo.h中的以下'冗余包含保护':
#ifndef fooH
    #include "foo.h"
#endif
此外,如果编译器不够智能,如果它们包含在源文件中,那么"冗余包括警卫"是必需的.例如use_foo.cpp.?
#pragma onceCodegear RAD Studio 2009 有什么相同的东西吗?
我正在使用预编译头向导,我想知道在包含头文件时是否仍然需要使用包含保护?