Reputation: 48058
Im writing a docstring in doxygen within a C comment block, and I want to include a snippet that contains /* text */
I know I could include a file, but this is just 8 characters or so. and it needs to be /* text */
, not // text
(since Im documenting the behavior of a C source code parser).
Is there some way to escape the characters so something like this is possible without causing problems for Doxygen or the compiler?
/**
* This is a doxy comment.
*
* This parser supports C style formatted comments: ``/* text */``
*/
Realize I could use C++ comments here for the main doxygen comment block. but still curious if this is possible without doing that (would mean changing a large comment block for this one snippet alone).
Upvotes: 2
Views: 1952
Reputation: 10144
I recently have been attempting the same thing for the purposes of a \code
block LaTeX output.
Simply leave a space between the trailing *
and /
. This does show as a space in the resultant PDF, but using it without the space appears exactly the same. The result is still correctly syntax-colored in the PDF but also allows your source to retain the correct syntax coloring and stops your source compiler throwing errors:
/**
\code{.c}
/* ... * /
\endocde
*/
Upvotes: 1
Reputation: 8861
Nesting comments is not possible...
C99 6.9.4 Comments
1 Except within a character constant, a string literal, or a comment, the characters /* introduce a comment. The contents of such a comment are examined only to identify multibyte characters and to find the characters */ that terminate it.70)
70) Thus, /* ... */ comments do not nest.
You have to do something like this:
/**
* This is a doxy comment.
*
* This parser supports C style formatted comments: /* text *//*
*/
Notice the difference:
/* text *//*
Upvotes: 1
Reputation: 9047
In version 1.8.7. ‍
exists (see chapter 24 HTML commands of the documentation). Did you try (it is a bit of a trick):
This parser C supports style formatted comments: /‍* text *‍/
Upvotes: 4