How to add "/*" in C++ comments?

M

Morgan Cheng

I'm using gcc 3.2.3.
I'd like to add some detailed tutorial to my comments about the usage of
the code. The tutoril includes some URI like "./ABC/CDE/*". The compiler
thinks that I am using "/*" in "/* */" and doesn't pass.
Is there any solution to add "/*" in "/* */" comments?
Thanks
 
P

puzzlecracker

Morgan said:
I'm using gcc 3.2.3.
I'd like to add some detailed tutorial to my comments about the usage of
the code. The tutoril includes some URI like "./ABC/CDE/*". The compiler
thinks that I am using "/*" in "/* */" and doesn't pass.
Is there any solution to add "/*" in "/* */" comments?
Thanks


use //* example: /* //* tutorial //* */
 
S

shez

Morgan said:
I'm using gcc 3.2.3.
I'd like to add some detailed tutorial to my comments about the usage of
the code. The tutoril includes some URI like "./ABC/CDE/*". The compiler
thinks that I am using "/*" in "/* */" and doesn't pass.
Is there any solution to add "/*" in "/* */" comments?
Thanks

For multi-line comments, I prefer to use "#if 0" and "#endif":

someCode();
#if 0
multiline comment
goes here
#endif
moreCode();

This has several advantages:
-> solves your problem regarding the closing */
-> allows you to create "nested" comments (easier when debugging)
-shez-
 
D

David Fisher

Morgan asked:
I'd like to add some detailed tutorial to my comments about the usage of
the code. The tutoril includes some URI like "./ABC/CDE/*". The compiler
thinks that I am using "/*" in "/* */" and doesn't pass.
Is there any solution to add "/*" in "/* */" comments?

Is there any reason not to use "//" comments ? Example:

// The files match the pattern ./ABC/DEF/*

David Fisher
Sydney, Australia
 
P

puzzlecracker

shez said:
usage

For multi-line comments, I prefer to use "#if 0" and "#endif":

someCode();
#if 0
multiline comment
goes here
#endif
moreCode();

This has several advantages:
-> solves your problem regarding the closing */
-> allows you to create "nested" comments (easier when debugging)
-shez-

shez could you illistrate with an example?
 
P

puzzlecracker

shez said:
usage

For multi-line comments, I prefer to use "#if 0" and "#endif":

someCode();
#if 0
multiline comment
goes here
#endif
moreCode();

This has several advantages:
-> solves your problem regarding the closing */
-> allows you to create "nested" comments (easier when debugging)
-shez-
 
R

Raymond Martineau

Morgan asked:


Is there any reason not to use "//" comments ? Example:

// The files match the pattern ./ABC/DEF/*

That works for single line comments, but detailed tutorials can be a little
cumbersome. The "#if 0" or "/*" are normally preferred for multi-line, as
they are much easier to work with (especially with word-wrap enabled, as on
most newsreaders.)

As for the OP, GCC 3.4.3 compiles "./ABC/CDE/*" without problem, aside from
an optional warning. It only becomes an issue if you try something fancy
like "/dev/*/*".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,199
Messages
2,571,045
Members
47,643
Latest member
ashutoshjha_1101

Latest Threads

Top