Imagine a C preprocessor block:
#if defined( NAME ) ... #else // comment-else ... #endif // comment-endif
Such blocks can be quite large and confusing.
To clarify intent and behavior, how could you write comment-else and comment-endif as a NAME expression?
Note. I must add that I am particularly interested in more complex cases with combined expressions and nesting.
#if defined(NAME) #else // defined(NAME) #endif // defined(NAME)
This, if used in your source, is very clear.
Em..
#if defined( NAME ) ... #else // NAME ... #endif // NAME
cannot become more obvious than that ...
#if defined(NAME) ... #else // !defined(NAME) ... #endif // defined(NAME)
, #else // condition , #elif condition. , , ( , , SO), , , . .
#else // condition
#elif condition
If you reorganize the "large and complex" code to separate functions, you can easily see the entire section at once.
#if defined NAME do_something_for_name(); #else do_something_without_name(); #endif
Really no special comment conventions are needed, right?
#if defined( NAME ) ... #else /* Else part of NAME */ ... #endif /* End of NAME */
This is how I do it.
When reading / viewing code (provided that you use the VIM editor on Linux), % is (Shift + 5) easy for us to switch from #ifto #elseand to #endif.
(Shift + 5)
#if
#else
#endif
Source: https://habr.com/ru/post/1795463/More articles:Kernel binding with MonoTouch - c #Environment variables for dll are different than exe - c ++Defining a Silverlight combobox popup (dropup) - silverlightProblem with ruby ββnested timeouts over system calls - multithreadingReading JS variable from BHO in IE9 - windowsWhat is the meaning of non-atomic and stored in the declaration of properties - propertiesWhy don't we have stateful protocols running on the Internet? - httpHigh Volume Erlang - loggingRun the specified command on error without try / catch in Matlab - matlabC # parser calculation - stringAll Articles