- Always use \\ style comments where possible. This allows you to use /* style comments for commenting out large blocks of code when debugging. If you want to comment a block of code which has /* comments inside it, you will run into problems! (unfortunately, */ style comments don’t nest in c).
- However, sometimes you still need to comment out blocks of code which have /* comments already inside them (maybe your using someone else’s code?). To do this, you can use the preprocessor trick #if 0 (see code below).
// This is a single lined comment, and the preferred way of doing things
/* This is
And should be used sparingly as these don't nest */
// The following example shows how you can comment out code blocks
// containing "/*" comments using the pre-processor and "#if 0"
/* Annoying multi-line
comment in a block
of code you want to comment */
#endif // #if 0
C Supports URL’s, Wait What?
Did you know that:
is valid syntax in C? Wait, what? O.K., I was lying, C doesn’t support URL’s, but the syntax is still valid! What it actually represents is a label ( http:), followed by a single-line comment ( //www.google.com).
Some people put function descriptions after the function name and parameters, and before the opening curly brace (for example, some windows driver files). I find this method weird and hard to read.
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
Installable driver initialization entry point.
This entry point is called directly by the I/O system.
DriverObject - pointer to the driver object
RegistryPath - pointer to a unicode string representing the path,
to driver-specific key in the registry.
STATUS_SUCCESS if successful,
rest of function code...
Doxygen is a powerful documentation generator that can be used with the C language. For more information and code examples with Doxygen, go to the Doxygen page.
Posted: April 14th, 2013 at 5:30 pm
Last Updated on: August 15th, 2017 at 10:50 am