Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a2ed2d9bf132b68b76aacb6d9c0809ddc08ba5d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Comments</title>
<link rel="stylesheet" type="text/css" href="../help.css">
</head>

<body>
<div role="main">
<h1>Comments</h1>
<p>Comments are lines in a source file that have been marked to be ignored by the compiler.
Two styles of comments are supported by current C/C++ compilers:</p>
<ul>
<li><samp>/* text */</samp></li>
<li><samp>// text</samp></li>
</ul>

<h2>Comment</h2>
<p>You can quickly comment out one or more lines of code by inserting the leading 
characters <samp>//</samp> at the beginning of the line.  To do so, select the line 
(or lines) of code you want to comment out and press <strong>CTRL+/</strong> (slash).</p>

<h2>Uncomment</h2>
<p>To uncomment  select the line (or lines) of code, and press <strong>CTRL+\</strong> 
(backslash).

<p><strong>Tip:</strong> The characters <samp>/* */</samp> on lines that are 
already commented out, are not affected when you comment and uncomment code.</p>

<h2>Multiline comment</h2>
<p>You can use the Content Assist feature to insert a multi-line comment before a function.
In the C++ editor, type <span class="typewriter">com</span> then press <strong>Ctrl+Space</strong>.
Select <span class="typewriter">default multiline comment</span> template and press <strong>Enter</strong>.
The following code is entered at the cursor location:
<br><pre>
/*
 * author userid
 *
 * To change this generated comment edit the template variable "comment":
 * Window > Preferences > C/C++ > Editor > Templates.
 */
 </pre>

 To change the default comment click <strong>Window > Preferences > C/C++ > Code Style > Code Templates</strong>.  For more information see the
 <a href="cdt_c_content_assist.htm">Content Assist</a> section.
 
 <p><img src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
<br>
<a href="cdt_c_content_assist.htm">Content Assist and code completion</a></p>
<p><img src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
<br>
<a href="../tasks/cdt_t_cust_cpp_editor.htm">Customizing the C++ editor</a><br>
<a href="../tasks/cdt_t_comment_out.htm">Commenting out code</a></p>
<p><img src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
<br>
<a href="../reference/cdt_o_ceditor_pref.htm">C/C++ editor preferences</a></p>

<p>
<img src="../images/rh03_04.gif" ALT="Red Hat Copyright Statement"><br>
<img src="../images/ng00_04a.gif" ALT=" IBM Copyright Statement" >
</p>
</div>
</body>

</html>

Back to the top