https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85487
Bug ID: 85487
Summary: Support '#pragma region' and '#pragma endregion' to
allow code folding with Visual Studio
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: austinpmorton at gmail dot com
Target Milestone: ---
#pragma region is a feature introduced by Microsoft in order to allow manual
grouping and folding of code within Visual Studio. It is entirely ignored by
the compiler. Clang has supported this feature since 2012 when in MSVC
compatibility mode, and enabled it across the board 3 months ago.
As it stands, you cannot use #pragma region within GCC without disabling
unknown pragma warnings, which is not advisable.
I propose GCC adopt "#pragma region" and "#pragma endregion" in order to
alleviate these issues. Because the pragma has no purpose at compile time, the
implementation would be trivial.
Microsoft Documentation on the feature:
https://docs.microsoft.com/en-us/cpp/preprocessor/region-endregion
LLVM change which enabled pragma region across the board:
https://reviews.llvm.org/D42248
Example usage and resulting compiler output:
https://godbolt.org/g/uJv6u4