In the online manual, I can see,
Nested functions are supported as an extension in GNU C, but are not supported by GNU C++.
What does that mean? How do I get that extension?
In the online manual, I can see,
Nested functions are supported as an extension in GNU C, but are not supported by GNU C++.
What does that mean? How do I get that extension?
You don't need to get the extension. That is a feature embedded in the GNU C
compiler.
FWIW, the extension here point to the extension over the C standard(s). To elaborate, from the online manual
6 . Extensions
GNU C provides several language features not found in ISO standard C. (The -pedantic option directs GCC to print a warning message if any of these features is used.) To test for the availability of these features in conditional compilation, check for a predefined macro GNUC, which is always defined under GCC.
Every C compiler supports one or several versions of the language, which could be standard or unofficial versions. For example, GCC supports three versions of the standard, see https://gcc.gnu.org/onlinedocs/gcc/Standards.html#Standards.
In addition, GCC supports so-called extensions, additional features for the language, that may exist for developer convenience, or for the purpose of testing experimental features that may make it into later versions of the official C standard. These extensions are enabled by default, so there is no additional package to install, they are just an integral part of the compiler itself.
These extensions should mostly only be used if the specific compiler is the only supported target for the project. Developers usually prioritize portability and conformance to the standards to maximize maintainability of a code base.
About this specific feature, it is important to note that C++11 added the support for lambda functions which probably justifies the lack of support of this extension in G++, as they would conflict without any additional benefit.
1st. The link you mention is for the current GCC development version. At this moment it's v6.0.0. I think you are not really using that. Very likely you are running some v4 or v5 compiler. Try gcc -v
to check.
2nd. GCC has a few command line options that control the exact "dialect" you are willing to use. In the specific case, nested functions are not in any current standard (AFAIK) so you need to ensure you are selecting a GNU dialect. The default one is called gnu89
that is "ISO C90 (including some C99 features)". The option -std=gnu11
should select "the most advanced dialect"™. A complete read of the documentation is highly recommended, though.
3rd. Once you know which version you are running you can go to the relevant online documentation and check in the "Extensions to the C Language Family" (I linked to v4.9.3 as an example) whether that extension is available and what's actually about.
I'd say, that's it.