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 :)
-
you cannot use variable length arrays in c++.. – Geno C Aug 13 '20 at 23:11
-
Re: `How to silence` - don't use them, they are not standard – Vlad Feinstein Aug 13 '20 at 23:12
-
2The best way is to remove variable length arrays. Go to your source code and replace the VLAs with `std::vector` – Thomas Sablik Aug 13 '20 at 23:12
-
1Closely related: [Why aren't variable-length arrays part of the C++ standard?](https://stackoverflow.com/questions/1887097/why-arent-variable-length-arrays-part-of-the-c-standard) I'm waffling over whether or not I should dupe-hammer, so I'll punt. – user4581301 Aug 13 '20 at 23:22
-
@user4581301 agreed. – Geno C Aug 13 '20 at 23:28
-
C++ does not support C99's variable length arrays. Use `std::vector`. – Eljay Aug 13 '20 at 23:31
2 Answers
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.

- 57,834
- 11
- 73
- 112
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/

- 557
- 4
- 9