C preprocessor: Difference between revisions

Content deleted Content added
Add: journal, title. | Use this tool. Report bugs. | #UCB_Gadget
No edit summary
Tags: Mobile edit Mobile app edit iOS app edit App section source
Line 396:
The <code>#region</code> and <code>#endregion</code> directives in C# are used to expand/collapse sections of code in IDEs, and has no effect on actual compilation of the program. It is primarily used for code organisation and readability.
<syntaxhighlight lang="csharp">
#region Helper Methodsmethods
 
void Log(string message)
Line 406:
</syntaxhighlight>
 
While this directive does not exist in C/C++, MSVC and Visual Studio instead have <code>#pragma region</code> and <code>#pragma endregion</code>.<ref>{{Cite web|url= https://learn.microsoft.com/en-us/cpp/preprocessor/region-endregion|title = region and endregion pragma}}</ref> Thus the equivalent C++ code would be:
This directive does not exist in C/C++.
 
<syntaxhighlight lang="c++">
#pragma region Helper methods
 
void log(const std::string& message) {
std::println(message);
}
 
#pragma endregion
</syntaxhighlight>
 
== Other uses ==