I found out that we can hide code in VScode using #pragma region
and #pragma endregion
. I have two questions:
#pragma region
work?Nayeon is Mia from The Princess Diaries, Jeongyeon and Sana are Molly and Sam from Ghost, Mina and Dahyun are Vic and Matthieu from La Boum, Sana and Tzuyu are Mia and Vincent from Pulp Fiction, Jeongyeon and Tzuyu are Romeo and Juliet from Romeo + Juliet, Jihyo and Jeongyeon are Itsuki/Hiroko and male Itsuki from Love ...
Slide back in time as Live Twice takes you to mid-century Japan. The newest brand in the Jigger & Pony family, Live Twice welcomes guests from all walks of life, united by their love of cocktails. Whether you're a salaryman or a creative, Live Twice welcomes your most authentic self at the end of the day.
It includes the title track of the same name produced by Park Jin-young. Twice members Jeongyeon, Chaeyoung, and Jihyo also took part in writing lyrics for two songs on the EP. What Is Love?
The #pragma region
is specific to Visual Studio only.
Using #pragma region
you can specify a block of code where you can expand it and collapse it.
It has no affect on compilation.
Here is an example:
// pragma_directives_region.cpp
#pragma region Region_1
void Test() {}
void Test2() {}
void Test3() {}
#pragma endregion Region_1
int main() {}
You can read more about it here.
Like others have mentioned your compiler is allowed to silently ignore a pragma
, Some will even give a warning depending on the specific compiler you are using. You need to read about your compiler's docs on pragma
.
gcc -Wall
also check for unknown pragma
s.
First, #pragma
is a C preprocessor directive. You're undoubtedly familiar with the #include
and #define
directives. Directives are used by the C preprocessor to perform certain actions before the code reaches the compiler.
The #pragma
directive in particular is meant to pass implementation-specific information to whatever compiler you're using.
Here's what GNU has to say:
The
#pragma
directive is the method specified by the C standard for providing additional information to the compiler, beyond what is conveyed in the language itself.
Here's what Microsoft has to say:
Pragma directives specify machine-specific or operating system-specific compiler features.
Second, for Microsoft Visual Studio and Visual Studio Code, the #pragma region
directive defines a region of code that the compiler's UI can use for code-folding (that is, hiding and showing blocks of code for readability). If a compiler cannot understand the #pragma region
directive, then the directive is ignored.
Here's an example below:
private:
chunk of code. Note that when I mouse-over the UI, there is a down arrow chevron (⌄) to indicate foldable code for the comment block but not for the private:
block.#pragma region foo
and ending #pragma endregion
will identify a block of code for code-folding. Notice that after the two #pragma
directives are added, the code-foldable chevron symbol appears in the UI.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With