LaurenFish
LaurenFish

Reputation: 11

How to silence Xcode warning: "variable length arrays are a C99 feature [-Wvla-extension]"?

I am very confused by the format of Xcode, and have tried to look around to by advice: "invert the flag" that shows up when we get these warnings. If someone could walk me through how to get to that page to silence this warning. I would be VERY grateful :)

Upvotes: 1

Views: 4050

Answers (2)

Omar Ghannou
Omar Ghannou

Reputation: 617

I propose to NOT use VLAs (variable Length Arrays) because they are out of the standard and unsafe, but if necessary, you can use

 #pragma clang diagnostic ignored "-Wwarning-name"

Replace warning-name with the warning name to silence

I assume that you are using clang, but if you are using GCC, replace clang with GCC.

Here is a link may also be help:

https://davedelong.com/blog/2018/12/15/silencing-specific-build-warnings/

Upvotes: 1

cigien
cigien

Reputation: 60278

You shouldn't use variable-length arrays. They are not a part of standard c++, and you should use a std::vector instead.

However, if you want to turn off a specific warning such as -Wvla-extension then you can explicitly suppress this warning by adding the -Wno-vla-extension flag when compiling the program.

You can add this flag to wherever you would normally put such flags in Xcode.

Upvotes: 4

Related Questions