简体   繁体   中英

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:)

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.

I advise you to Not use VLAs (variable Length Arrays) as they are out of the standard and not safe but in case you know what you are doing you can use

 #pragma clang diagnostic ignored "-Wwarning-name"

change warning-name by your warning name

I assume you are using clang. if you are using GCC replace clang by GCC.

here is a link may help also: https://davedelong.com/blog/2018/12/15/silencing-specific-build-warnings/

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