Initialising variables in C++ with {}

  c++, clang, initialization, macos, visual-studio-code

I am using C++ in Visual Studio Code. When I want to initialise a variable I cannot initialise it with {} (e.g., int x {0};). Instead, I have to use () (e.g., int x (0);).

The error I get when using {} is "error: expected ‘;’ at end of declaration" Although I have put ; at the end of declaration.

I’m using clang 11.0.0 as the compiler. Is it related to the compiler?

Source: Windows Questions C++