C preprocessor: Difference between revisions

[unchecked revision][unchecked revision]
Line 101:
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 :
<source lang="c">
#if 0
print("memory state: ");
print(mem->"memory state: ");
print("\nallocated blocks: "mem->state);
print(mem->allocs"\nallocated blocks: ");
print("memory state: "mem->allocs);
#endif
</source>
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.
 
 
=== Hazards of the C preprocessor ===
Anonymous user