简体   繁体   中英

C++Builder > binary number 0b1 causes error E2141

I am using C++ Builder XE4.

I am trying to use a binary number such as 0b1 in my code.

Following is the code I tried:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    int num = 0b11;
}

The above causes a compiler error:

Unit1.cpp(19): E2141 Declaration syntax error

Does C++Builder support binary numeration like this?

I confirmed that 0x11 works in C++Builder.

I also confirmed that 0b11 can be used in IDEOne using C++:

http://ideone.com/oy4aIZ

Binary notation of integer literals is a new feature in C++14 . However, no C++Builder version has a C++14 compiler at this time.

In XE4, the Win32 compiler and OSX compiler do not support C++11 at all (a 32bit C++11 compiler was added in 10.0 Seattle). The Win64 compiler supports C++11, though.

The current C++Builder compilers support only decimal, octal, and hex. See Embarcadero's documentation for details: Integer Constants

如果要编译它,则需要更新版本的C ++ Builder和C ++ 11编译器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM