C preprocessor: Difference between revisions

m
no edit summary
[unchecked revision][unchecked revision]
No edit summary
mNo edit summary
Line 9:
A code block may be commented out to delete it from the program, however nesting deleted fragments may reduce legibility with C++ style comments, and C comments do not nest at all.
A better solution is to wrap the code in and #if 0-#endif block, where the conditional 0 means false :
#if 0
[code]
#if 0
print("memory state: ");
print(mem->state);
print("\nallocated blocks: ");
print(mem->allocs);
#endif
[/code]
Many editors, like [[VIm]] have by default syntax highlighting rules that treat such #if 0-#endif blocks as comments.
The #if-#endif directives must be balanced, single-quotes characters must balance etc. so for deleting non-code text use comments instead.
Anonymous user