Reputation: 3
I tried compiling a simple program using clang but I got following error code:
kassa.cpp:7:13: error: expected ';' at end of declaration
double mwst{0.8};
^
;
1 error generated.
I downloaded clang 3.8-36 on a debian based system using the command:
sudo apt-get install clang
For some reason it works with gcc or using assignments, but I want it to work normally with clang as well.
Upvotes: 0
Views: 181
Reputation: 22162
You are using quite an old version of Clang, which uses the old C++98 standard by default.
You need to add the -std=c++11
option to the compiler command line in order to support C++11 or -std=c++14
for C++14. The type of initialization with braces that you are trying to use was introduced with C++11.
Your are advised to upgrade Clang to a more recent version, because that version is not going to support any more recent C++ standard versions such as the current C++17 and the upcoming C++20.
Since you installed it through apt-get
this also suggests that you are using an old Linux distribution, which may be fine if it is still supported (e.g. Ubuntu 16.04 LTS). If not, I would urge you to upgrade your whole system. But even if, you might want to consider upgrading to more easily use new software features.
Upvotes: 2