Skip to content

Commit bfe56e0

Browse files
Update book/en-us/02-usability.md
Co-authored-by: A. Jiang <[email protected]>
1 parent 2372cb4 commit bfe56e0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

book/en-us/02-usability.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ we need to use the `constexpr` feature introduced in C++11, which will be introd
147147
to solve this problem; for `arr_5`, before C++98 The compiler cannot know that `len_foo()`
148148
actually returns a constant at runtime, which causes illegal production.
149149
150-
> Note that some compilers (e.g. GCC, Clang) have compiler extensions enabled by default, supporting a C feature called "[variable-length arrays](https://en.cppreference.com/w/c/language/array#.E9.9D.9E.E5.B8.B8.E9.87.8F.E9.95.BF.E5.BA.A6.E6.95.B0.E7.BB.84)", which allows you to define an array whose length can be a non-constant expression. Code that causes the above comments to be illegal can be compiled. To disable the extension, add the compilation option [`-pedantic-errors`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-pedantic-errors) (both GCC and Clang are available).
150+
> Note that some compilers (e.g. GCC, Clang) have compiler extensions enabled by default, supporting a C feature called "[variable-length arrays](https://en.cppreference.com/w/c/language/array#Variable-length_arrays)", which allows defining an array whose length is a non-constant expression and causes the above commented out illegal code to be compilable. To disable the extension, add the compilation option [`-pedantic-errors`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-pedantic-errors) (available for both GCC and Clang).
151151
152152
C++11 provides `constexpr` to let the user explicitly declare that the function or
153153
object constructor will become a constant expression at compile time.

0 commit comments

Comments
 (0)