Skip to main content
summaryrefslogtreecommitdiffstats
blob: 76b5c2c6bffb8fe70e992d1fa2ceb6f8e97452d6 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.ord/TR/html4/loose.dtd">
<html>

<head>

<title>Developing C/C++ Programs</title>

</head>
<body bgcolor="#ffffff" text="#000000">
<hr>


<h1><a name="id1">Developing C/C++ Programs</a></h1>




<p>

The <b>C/C++ Development</b> perspective is probably the perspective 
where you'll spend most of your time. In it, you'll develop and build 
your programs. As you move further through your project, you'll likely 
use this perspective as the jump point for doing your debugging, program 
analysis, and target system integration.</p>
<p>

Suggested prior reading:</p>
<ul>
<li>the <a href="conc.html">IDE Concepts</a> chapter</li>
</ul>
<p>

Related information:</p>
<ul>
<li>the <a href="cwiz.html">Common Wizards</a> chapter
   </li>
<li>the <a href="lnch.html">Starting Your Programs</a> chapter
   </li>
</ul>
<p></p>
In this chapter:

<ul>
<li><a href="#how">Introduction</a>
   </li>
<li><a href="#view_c_projects">Controlling the IDE (C/C++ Projects view)</a>
   </li>
<li><a href="#creating">Creating projects (New Projects wizard)</a>
   </li>
<li><a href="#building">Building projects ( <tt>make</tt>)</a>
   </li>
<li><a href="#running">Running programs (launcher)</a>
   </li>
<li><a href="#editor_c">Writing code (C/C++ Editor)</a>
   </li>
<li><a href="#more">More development features</a>
   </li>
</ul> 

<h1><a name="how">Introduction</a></h1>


<p>

Before you begin C/C++ development, you must create a project to contain your code; in the IDE, all your work must be contained in projects.</p>
<p>

The views in the <b>C/C++ Development</b> perspective are driven primarily by selections you make in the <b>C/C++ Editor</b> and the <b>C/C++ Projects</b> view, a specialized version of the <b>Navigator</b> view. Ensure you understand their functionality thoroughly.

</p>

<h2><a name="id4">Wizards and the Launch Configurations dialog</a></h2>

<p>In addition to perspectives and views, the IDE has two major "sections": wizards and the <b>Launch Configurations</b> dialog. To create and run your first program, you need both. The wizards let you quickly create a new project; the <b>Launch Configurations</b> dialog lets you set up how your program runs. 
Once you've used all these parts of the IDE for the first time, you'll be able to create, build, and run your programs very quickly. For more information, see the <a href="cwiz.html">Common Wizards</a> and <a href="lnch.html">Starting Your Programs</a> chapters.</p>
<p>

The <b>C/C++ Development</b> perspective also has many features that help you develop code quickly. Once you've learned the basics of creating programs and running them (in this chapter), take some time to browse through this chapter. </p>
<p>

 </p>

<h1><a name="view_c_projects">Controlling the IDE (C/C++ Projects view)</a></h1>

<p><img src="./images/view_cprojects.jpg" alt="C/C++ Projects view"></p>
<p>The <b>C/C++ Projects</b> view is probably the most important view in the IDE because you control your projects with it. The selections you make in the <b>C/C++ Projects</b> view greatly affect what information the other views display.</p>
<p>

The <b>C/C++ Projects</b> view offers a filtered and slightly rearranged version of the <b>Navigator</b> view. </p>
<p>The <b>Navigator</b> view is part of the core Eclipse platform, so some of the features are documented there:

</p>
<ul>
<li>For information about the <b>Navigator</b> view toolbar and icons, follow these links in the <cite>Workbench User Guide</cite>: <b>Concepts</b>--><b>Views</b>--><b>Navigator view</b>.
   
   </li>
<li>For information about the right-click context menu in the <b>Navigator</b> view, follow these links in the <cite>Workbench User Guide</cite>: <b>Reference</b>--><b>User interface information</b>--><b>Views and Editors</b>--><b>Navigator View</b>.
   </li>
</ul>
<p>The <b>C/C++ Projects</b> view has many of the same features as the <b>Navigator</b> view, but is configured specifically for C and C++ development. At first glance, the two may seem identical, but the <b>C/C++ Projects</b> view:</p>
<ul>
<li>shows only open C/C++ projects
   </li>
<li>pretends that the project's executables are stored in a virtual subdirectory called <tt>bin</tt>
   </li>
<li>for a library project, pretends that the project's libraries are in a virtual subdirectory called <tt>lib</tt>
   </li>
<li>hides certain files
   </li>
<li>includes <b>Build Project</b> and related commands in its right-click menu
   </li>
<li>gives an outline of <tt>*.c</tt>, <tt>*.cc</tt>, <tt>*.cpp</tt>, <tt>*.h</tt>, and binary files.
   </li>
</ul>

<h2><a name="id7">Opening files</a></h2>

<p>To open files and display them in the editor area:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>C/C++ Projects</b> view, double-click the file to be opened.
The file  --  even if it's executable  --  opens in the editor area.</td></tr>
</table>



<h2><a name="id9">Opening projects</a></h2>

<p>Because the <b>C/C++ Projects</b> view hides closed projects, you must use the <b>Navigator</b> view to open them.</p>
<p>

To open projects:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>Navigator</b> view, right-click your project, and select <b>Open Project</b>.
The project opens and appears in the <b>C/C++ Projects</b> view.</td></tr>
</table>



<h2><a name="id11">Filtering files</a></h2>

<p>To filter files in the <b>C/C++ Projects</b> view:</p>
<ol>

<li>In the <b>C/C++ Projects</b> view, click the menu dropdown button <img src="./images/icon_menu.gif" alt="Icon; menu dropdown">.
   </li>
<li>Select <b>Filter</b>.
   The <b>File Filter</b> dialog appears:<p>   	<img src="./images/view_cprojects_filter.jpg" alt="C/C++ Projects view; File Filter dialog">
   </p></li>
<li>In the filter pane, select the types of files you wish to hide. The <b>.*</b> selection hides files that start with a period, such as <tt>.cdtproject</tt> and <tt>.project</tt>.
   </li>
<li>Click <b>OK</b>.
   The <b>C/C++ Projects</b> view automatically refreshes and shows only the unfiltered file types.
   </li>
</ol>


<h2><a name="id13">Outlines of source and executable files</a></h2>

<p>

The <b>C/C++ Projects</b> view shows you the outline of <tt>.c</tt>, <tt>.cc</tt>, and <tt>.h</tt> files:</p>
<p><img src="./images/view_cprojects_outline_source.jpg" alt="C/C++ Projects view; outline; source"></p>
<p>This outline is similar to that found in the <b>Outline</b> view. To learn more about the <b>Outline</b> view, see the <a href="#view_outline">"Code synopsis (Outline view)"</a> section in this chapter.</p>
<p></p>
<p>The <b>C/C++ Projects</b> view shows you the outlines of executables as well. You can examine the structure of executables to see not only the functions that you declared and used in the file, but the elements that were called indirectly, such as <i>malloc()</i>, <i>_init()</i>, and <i>errno</i>:</p>
<p><img src="./images/view_cprojects_outline_executable.jpg" alt="C/C++ Projects view; outline; executable"></p>
 </p>
<p>To view a file outline in the <b>C/C++ Project</b> view:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>C/C++ Projects</b> view, click the "+" symbol to the left of any <tt>.c</tt>, <tt>.cc</tt>, or <tt>.h</tt>, or executable file. All the executables are grouped in the virtual <tt>bin</tt> directory. The tree expands to show the outline for that file. Click the "-" symbol to collapse the tree again.</td></tr>
</table>



<h1><a name="creating">Creating projects (New Project wizard)</a></h1>

<H3>
@@@ NOTE I've left this in even though it is QNX specific, we would have to 
customize it to make it CDT generic 
</H3>

<p>If you're creating an application from scratch, you'll probably want to create a <b>QNX C Application Project</b> or a <b>QNX C ++ Application Project</b>. </p>
<p></p>

<hr>
<table>
<tr><td valign="top"><img src="image-lib/pointing.gif" alt="Note:"></td>
<td>For examples of creating specific types of projects, see the <cite>Tutorials</cite> book. We recommend that you create a few tutorial projects before you do too much reading. Having hands-on experience with the IDE gives you a better context for what you read in this guide.
<p>

For a complete explanation of all the C/C++ project types and options, see the <a href="cwiz.html">Common Wizards</a> chapter.</p></td></tr>
</table>
<hr>


<p>To create a "Hello World!" <b>QNX C Application Project</b>:</p>
<ol>

<li>In the <b>C/C++ Development</b> perspective, click the <b>Create a new QNX C Application Project</b> button <img src="./images/icon_newcqnx_app.gif" alt="Icon: Create a QNX C Application Project button">.
   The <b>New Project</b> dialog appears:<p>   <img src="./images/cwiz_c.jpg" alt="Wizard: Create a QNX C Application Project"> 
   </p></li>
<li>In the <b>Name</b> field, type a name for your project (e.g. <tt>myHelloWorldProject</tt>).
   </li>
<li>Click <b>Next</b>. The dialog displays the appropriate with tabs.
   </li>
<li>In the <b>Options</b> tab, enable <b>Build debug version</b> and <b>Build release version</b>:<p>	<img src="./images/cwiz_c_options.jpg" alt="Common wizards: C/C++ Projects; Options tab">

   </p></li>
<li>Click <b>Finish</b>.
   The IDE creates the project and displays the C file (e.g. <tt>myHelloWorldProject.c</tt> in the <b>C Editor</b>. It contains a working "Hello, World!" program:<p>   <img src="./images/editor_c_helloworld.jpg" alt="C/C++ Editor; Hello World! program">
   </p></li>
</ol>


<h1><a name="building">Building projects (<tt>make</tt>)</a></h1>

<p>Once you've created your project, you can build it. The IDE uses the same <tt>make</tt> utility and makefiles used on the command line. The IDE can perform makes automatically or let you do them manually. When you do manual builds, you can also decide on the scope of the build.</p>
<p>

You can watch the progress and see the build information in the <b>C-Build</b> view. If building your programs generates any errors or warnings, you can see them in the <b>Tasks</b> view.</p>
<p>This section includes:</p>
<ul>
<li><a href="#make_terminology">Build terminology</a>
   </li>
<li><a href="#make_choosing">Choosing autobuild or manual build</a>
   </li>
<li><a href="#make_auto">Autobuilds</a>
   </li>
<li><a href="#make_manual">Manual builds</a>
   </li>
<li><a href="#make_configuring">Configuring the project build order</a>
   </li>
<li><a href="#make_personaloptions">Creating personal build options (<tt>make</tt> targets)</a></li>
</ul>

<h2><a name="make_terminology">Build terminology</a></h2>

<p>The IDE uses a number of terms to describe the scope of the build:

</p>
<dl>

<dt><b>Build</b>
	</dt>
<dd>Build only the components affected by modified files in that particular project (i.e. <tt>make all</tt>).
	</dd>
<dt><b>Clean</b>
	</dt>
<dd>	Delete all the built components (i.e. <tt>.o</tt>, <tt>.so</tt>, <tt>.exe</tt>, and so on) without building anything (i.e. <tt>make clean</tt>).
	</dd>
<dt><b>Rebuild</b>
	</dt>
<dd>Build every component from scratch. A <b>Rebuild</b> is really a <b>Clean</b> followed by a <b>Build</b> (i.e. <tt>make clean; make all</tt>).

</dd>
</dl>


<h2><a name="make_choosing">Choosing autobuild or manual build</a></h2>

<p>By default, the IDE automatically rebuilds every time you change a resource (e.g. file). This is handy if you have only a few open projects and if they're small. As the projects get larger, this feature can become a bit of a hindrance. You may find that you prefer to turn autobuilding off.</p>
<p>

To turn off autobuilding:</p>
<ol>

<li>From the main menu, select <b>Window</b>--><b>Preferences</b>.
   </li>
<li>In the left pane, select <b>Workbench</b>.
   The dialog displays your workbench preferences:<p>   <img src="./images/window_preferences_workbench.jpg" alt="Window; Preferences; Workbench">
   </p></li>
<li>In the right pane, disable the <b>Perform build automatically on resource modification</b> option. The IDE now builds only when you ask it to.

</li>
</ol>


<h2><a name="make_auto">Autobuilds</a></h2>

<p>

The IDE builds automatically every time you save a change. Thus, if you're using the default IDE configuration, you don't need to do anything. Even in this setting, you can build manually as well. Because the IDE always does incremental builds while in autobuild mode, you may wish to manually do a clean build to ensure you have fresh executables.</p>

<h2><a name="make_manual">Manual builds</a></h2>

<p>Manual builds let you  choose the scope of the build, as well as whether to do a <b>Build</b>, a <b>Clean</b>, or a <b>Rebuild</b>.</p>

<h3><a name="id21">Building everything</a></h3>

<p>The IDE lets you manually choose to rebuild all your open projects. Depending on the number of projects, the size of the projects, and the number of target architectures, this can take a significant amount of time.</p>
<p>

To rebuild all your open projects:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>From the main menu, select <b>Project</b>--><b>Rebuild All</b>.</td></tr>
</table>



<h3><a name="id23">Building selected projects</a></h3>

<p>Because rebuilding all your open projects may be time-consuming, you may often wish to build only certain projects individually.</p>
<p>

To rebuild a single project:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>C/C++ Projects</b> view, right-click a project and select one of:
<ul>
<li><b>Build</b>
   </li>
<li><b>Rebuild</b>
   </li>
<li><b>Clean</b>.</li>
</ul>
<p>The IDE builds the selected project as you desired. For more information on the build methods, see the <a href="#make_terminology">"Build terminology"</a> section in this chapter.</p><p><img src="./images/view_cprojects_building.jpg" alt="C/C++ Projects view; building"></p></td></tr>
</table>



<h3><a name="id25">Manual build preferences</a></h3>

<p>To have the IDE save your unsaved resources before manual builds:</p>
<ol>

<li>From the main menu, select <b>Window</b>--><b>Preferences</b>.
   </li>
<li>In the left pane, select <b>Workbench</b>.
   </li>
<li>In the right  pane, enable the <b>Save all modified resources automatically prior to manual build</b> option. 
   The IDE saves your resources before it builds.</li>
</ol>


<h2><a name="make_configuring">Configuring project build order</a></h2>

<p>The IDE lets you determine the build order of your projects. If certain projects must be built before others, you can set that. If your project refers to another project, the IDE builds that project first.

</p>

<hr>
<table>
<tr><td valign="top"><img src="image-lib/pointing.gif" alt="Note:"></td>
<td>Setting the build order doesn't cause the IDE to rebuild projects that depend on the project; you must rebuild all projects to ensure all the changes are propagated.</td></tr>
</table>
<hr>


<p>

To manually configure the project build order:</p>
<ol>

<li>From the main menu, select <b>Window</b>--><b>Preferences</b>.
   </li>
<li>In the left pane, select <b>Build Order</b>.
   </li>
<li>Disable the <b>Use default build order</b> option.
   You may now configure the build order as you desire. When you're done, click <b>Apply</b>, then <b>OK</b>.</li>
</ol>


<h2><a name="make_personaloptions">Creating personal build options (<tt>make</tt> targets)</a></h2>


<hr>
<table>
<tr><td valign="top"><img src="image-lib/pointing.gif" alt="Note:"></td>
<td>In this subsection, "targets" refer to actions in the makefiles, not target machines.</td></tr>
</table>
<hr>


<p>A <tt>make</tt> <i>target</i> is an action called by the <tt>make</tt> utility to perform a customized build-related task. For example, many makefiles support a target named <tt><b>clean</b></tt>, which gets called as <tt>make clean</tt>. The IDE lets you call your own target such as <tt><b><i>myMakeAction</i></b></tt> to be called as <tt>make <i>myMakeAction</i></tt>. You can also use a <tt>make</tt> target to pass options such as <tt><b>CPULIST=x86</b></tt>, which causes the <tt>make</tt> utility to build only for x86. Of course, these options work only if they're already defined in the makefile. </p>
<p>

If you've added your own <tt>make</tt> targets, you can configure the IDE to call them specifically. </p>
<p>

To add a customized <tt>make</tt> target to the <b>C/C++ Project</b> view right-click menu:</p>
<ol>

<li>In the <b>C/C++ Projects</b> view, right-click a project and select <b>Add Make Targets</b>.
   </li>
<li>Type the name of the <tt>make</tt> target (e.g. <tt>myMakeOption</tt>):
   <p><img src="./images/view_cprojects_target_add.jpg" alt="C/C++ Projects view; Targets Dialog dialog">   </p></li>
<li>Click <b>OK</b>.
   The target option appears in the right-click menu of the <b>C/C++ Projects</b> view.</li>
</ol>

<p>

To use a customized <tt>make</tt> target:</p>
<ol>

<li>In the <b>C/C++ Projects</b> view, right-click a project. The right-click context menu appears. If there are any customized <tt>make</tt> targets for your project, the <b>Make</b> item is selectable.
   </li>
<li>Choose your make target from the <b>Make</b> menu:
   <p>   <img src="./images/view_cprojects_target_use.jpg" alt="C/C++ Projects view; make target; using"></p></li>
</ol>


<h1><a name="running">Running projects (launcher)</a></h1>
<H3>
@@@ Again the same thing applies here about stripping out the QNX
specific information (ie regarding needing a target for launch) and
replacing it with generic CDT information.  I've much of it in for
context.
</H3>
<p>

Once you've built your project, you'll want to run it. The IDE lets you 
run or debug your executables on either a local or a remote QNX Neutrino 
target machine. For a description of local and remote targets, see the 
<a href="conc.html">IDE Concepts</a> chapter. </p>
<p>

To run or debug your program, you must create a <b>QNX Target System Project</b> 
that specifies how the IDE communicates with your target. You must also create 
a <b>Launch Configuration</b> that describes how the program runs on your target. 
</p>

<hr>
<table>
<tr><td valign="top"><img src="image-lib/pointing.gif" alt="Note:"></td>
<td>For a complete description of the <b>Launch Configurations</b> dialog and the available options, see the <a href="lnch.html">Starting Your Programs</a> chapter.</p></td></tr>
</table>
<hr>

To run your "Hello World!" <b>QNX C Application Project</b>:</p>
<ol>

<li>In the <b>C/C++ Projects</b> view, select your project (e.g. <b><i>myHelloWorldProject</i></b>).
   </li>
<li>In the <b>C/C++ Development</b> perspective, click the dropdown menu <img src="./images/icon_menu.gif" alt="Icon: Menu dropdown"> part of the run menu button set <img src="./images/icon_run_exc.gif" alt="Icon: Run"><img src="./images/icon_menu.gif" alt="Icon: Menu dropdown">.
   </li>
<li>Select <b>Run</b>.
  The <b>Launch Configurations</b> dialog appears:<p>  <img src="./images/lnch.jpg" alt="Launcher">
   </p></li>
<li>In the left pane, select <b>C/C++ QNX QConn (IP)</b>.
   </li>
<li>Click <b>New</b>.
	The dialog displays the appropriate tabs:<p>   <img src="./images/lnch_main.jpg" alt="Launcher; Main tab">
   </p></li>
<li>In the <b>Name</b> field, type a meaningful name for your launch configuration (e.g. <tt>myHelloProject IP launch</tt>).
 The IDE automatically fills in the <b>Project</b> field.
   </li>
<li>Click the <b>Search</b> button beside the <b>C/C++ Application field</b>.
   The <b>Program Selection</b> dialog appears. 
	
<hr>
<table>
<tr><td valign="top"><img src="image-lib/pointing.gif" alt="Note:"></td>
<td>If the <b>Program Selection</b> dialog is blank, you must cancel and build your project. To learn how to build projects, see the <a href="#building">"Building projects (<tt>make</tt>)"</a> section.
	</td></tr>
</table>
<hr>


   </li>
<li>Select a program to run. The <tt>_g</tt> indicates it's compiled with debug symbols. If you wish to run on an x86 target, select <b>myHelloWorldProject [x86le]</b>
   </li>
<li>Click <b>OK</b>.
   </li>
<li>In the <b>Target Options</b> pane, select your target.
   </li>
<li>Click <b>Run</b>.
   Your program runs. The IDE displays the output in the <b>Console</b> view. For example:
   <p>   <img src="./images/view_console_helloworld.jpg" alt="Console view; Hello World!">
   </p></li>
</ol>


<h1><a name="editor_c">Writing code (C/C++ Editor)</a></h1>

<p>Within the C/C++ Development perspective, the <b>C/C++ Editor</b> is where you'll likely spend the great majority of your time  --  you use it to write and modify your code:</p>
<p><img src="./images/editor_c.jpg" alt="C/C++ Editor"></p>
<p>The <b>C/C++ Editor</b> drives many of the other views. As you code, many of the other views update dynamically (even if you haven't saved).</p>
<p>This section includes:</p>
<ul>
<li><a href="#c_editor_layout">C/C++ Editor layout</a>
   </li>
<li><a href="#c_editor_contentassist">Finishing function names (Content Assist)</a>
	</li>
<li><a href="#c_editor_codetemplates">Inserting code snippets (Code Templates)</a>
   </li>
<li><a href="#c_editor_addinclude">Adding <tt>#include</tt> directives (Add include)</a>
   </li>
<li><a href="#c_editor_help">Hover help</a>
   </li>
<li><a href="#c_editor_codecommenting">Commenting out code</a>
   </li>
<li><a href="#c_editor_customizing">Customizing the C/C++ Editor appearance</a>
   </li>
<li><a href="#c_editor_alternateeditors">Using other editors</a></li>
</ul>

<h2><a name="c_editor_layout">C/C++ Editor layout</a></h2>

<p>The <b>C/C++ Editor</b> has a gray border on each side. The border on the <em>left</em> margin might contain icons that flag errors, warnings, or problems detected by the IDE. It also displays icons for any bookmarks, breakpoints, or tasks from the <b>Tasks</b> view. The icons in the left margin correspond to the line of code.</p>
<p>The border on the <em>right</em> margin displays red and yellow bars that correspond to the errors and warnings from the <b>Tasks</b> view. Unlike the left margin, the right margin displays the icons for the entire length of the file.</p>
<p>


</p>

<h2><a name="c_editor_contentassist">Finishing function names (Content Assist)</a></h2>

<p>The IDE can help you finish the names of functions if they're long, or you can't remember the exact spelling.</p>
<p>

To use <b>Content Assist</b>:</p>
<ol>

<li>In the <b>C/C++ Editor</b>, type at least the first letter of the function.
	</li>
<li>Press <font face="Helvetica"><b>Ctrl</b></font>-<font face="Helvetica"><b>Space</b></font>. (Or, right-click near the cursor and select <b>Content Assist</b>).
	A menu with the available functions appears:<p>	<img src="./images/editor_c_contentassist.jpg" alt="C/C++ Editor; Content Assist">
	</p></li>
<li>You may do one of the following:
	<ul>
<li>Continue typing. The list shortens. When there's only one function that matches, it's automatically inserted.
		</li>
<li>Scroll with the up and down arrows. Press <font face="Helvetica"><b>Enter</b></font> to select the function.
		</li>
<li>Scroll with the mouse. Double-click a function to select it.
		</li>
<li>Press <font face="Helvetica"><b>Esc</b></font> to close the <b>Content Assist</b> window.
	</li>
</ul></li>
</ol>


<h2><a name="c_editor_codetemplates">Inserting code snippets (Code Templates)</a></h2>

<p>

The IDE can help you by inserting snippets of code such as an empty <tt>do-while</tt> structure. If you've used the <b>Content Assist</b> feature, you may have already noticed this feature; you access it the same way.</p>
<p>

To use <b>Code Templates</b>:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>Follow the procedure for using <b>Content Assist</b>, with the following exception:
<ul>
<li>If any code templates start with the letter combination you've typed, they appear first in the list and have a different icon:<p>	<img src="./images/editor_c_codetemplates_use.jpg" alt="C/C++ Editor; Code Templates; using"></p></li>
</ul></td></tr>
</table>


<p>To add <b>Code Templates</b>:</p>
<ol>

<li>From the main menu, select <b>Window</b>--><b>Preferences</b>.
   </li>
<li>In the left pane, select <b>C/C++</b>--><b>Code Templates</b>.
   </li>
<li>Click <b>New</b>.
   A dialog for adding new templates appears. You can view the format of existing templates by selecting them and clicking <b>Edit</b>: <p>   <img src="./images/window_preferences_c_codetemplates.jpg" alt="Window; Preferences; C/C++; Code Templates dialog"></p></li>
</ol>


<h2><a name="c_editor_addinclude">Adding <tt>#include</tt> directives (Add Include)</a></h2>

<p>To insert the <tt>#include</tt> directive for any documented QNX Neutrino function:</p>
<ol>

<li>In the <b>C/C++ Editor</b>, highlight the entire function name by double-clicking  it. Don't highlight the parentheses or any leading tabs or spaces.
   </li>
<li>Right-click and select <b>Add Include</b>.
   The IDE automatically adds the <tt>#include</tt> statement to the top of the file, if it isn't already there.</li>
</ol>


<h2><a name="c_editor_help">Hover help</a></h2>

<p>The IDE can give you information about functions while you're coding.</p>
<p>

To use hover help:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>C/C++ Editor</b>, place your pointer over a function.
A tag appears, showing the function summary and synopsis:<p><img src="./images/editor_c_hoverhelp.jpg" alt="C/C++ Editor; Hover help"></p></td></tr>
</table>



<h2><a name="c_editor_codecommenting">Commenting out code</a></h2>

<p>The IDE makes it easy to comment out large sections of code. You can quickly add <tt>//</tt> characters to the beginning of lines, letting you comment out large sections, even if they have <tt>/* */</tt> comments.
When you uncomment lines, the IDE removes the leading <tt>//</tt> characters from all lines that have them, so be careful not to accidentally uncomment sections. Also, the IDE comments or uncomments the selected lines  --  if you select a partial line, the IDE comments out the entire line, not just the highlighted section of code. </p>
<p>

To comment or uncomment a block of code:</p>
<ol>

<li>In the <b>C/C++ Editor</b>, highlight a section of code to be commented or uncommented. For one line,  place your cursor on that line.
   </li>
<li>Right-click and select <b>Comment</b> or <b>Uncomment</b>.
   </li>
</ol>


<h2><a name="c_editor_customizing">Customizing the C/C++ Editor appearance</a></h2>

<p>You can change the font, set the background color, display line numbers, and control many other visual aspects of the C/C++ Editor. You can also configure context highlighting, and change how the <b>Code Assist</b> feature works.

</p>
<p>To access the <b>C/C++ Editor</b> preferences dialog:</p>
<ol>

<li>Select <b>Window</b>--><b>Preferences</b>.
   The <b>Preferences</b> dialog appears.
   </li>
<li>In the left pane, select <b>C/C++</b>--><b>C/C++ Editor</b>.</li>
</ol>


<h2><a name="c_editor_alternateeditors">Using other editors</a></h2>

<p>The IDE lets you use other editors, but you should consider the added functionality the <b>C/C++ Editor</b> offers before changing.</p>
<p>

The <b>C/C++ Editor</b> is highly integrated with the IDE. The other views are designed to support the <b>C/C++ Editor</b> by updating dynamically. Since other editors aren't designed to interface with the IDE, you won't get the support from the views that the IDE provides.</p>
<p>

You can use other editors either outside or inside the IDE.

</p>

<h3><a name="c_editor_alternateeditors_outside">Outside  the IDE</a></h3>

<p>You can edit your code with an editor started outside of the IDE (e.g. from the command line). When you're done editing, you'll have to synchronize the IDE with the changes.</p>
<p>

To synchronize the IDE with changes you've made outside of the IDE:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>C/C++ Projects</b> view, right-click the tree pane and select <b>Refresh</b>.
The IDE updates to reflect any changes you've made (such as creating new files).</td></tr>
</table>



<h3><a name="c_editor_alternateeditors_within">Within the IDE</a></h3>

<p>

The IDE lets you set file associations that determine the editor you use for each file type. For example, you can tell the IDE to use an external program such as WordPad to edit all <tt>.h</tt> files. Once that preference is set, you can double-click a file in the <b>C/C++ Projects</b> view, and the IDE automatically opens the file in your selected program.</p>
<p>

If the IDE doesn't have a set association for a certain file type, it uses the OS defaults. Thus, in Windows, double-clicking on a <tt>.DOC</tt> file automatically opens the file in MS Word or WordPad.</p>
<p>

For information about file associations, follow these links in the Eclipse <cite>Workbench User Guide</cite>: <b>Reference</b>--><b>Preferences</b>--><b>File Associations</b>.</p>
<p> </p>

<h1><a name="more">More development features </a></h1>

<p>The IDE has many features that help you work faster. Not all the features are things you'd necessarily think to look for; after you've used the IDE for a while, take some time to read this entire section.</p>
<p>

This section includes:</p>
<ul>
<li><a href="#view_tasks">Tracking remaining work (Tasks view)</a>
   </li>
<li><a href="#view_outline">Code synopsis (Outline view)</a>
   </li>
<li><a href="#view_cbuild">Checking your build (C-Build view)</a></li>
</ul>

<h2><a name="view_tasks">Tracking remaining work (Tasks view)</a></h2>

<p>

The <b>Tasks</b> view provides you with a list of errors and warnings related to your projects. These are typically syntax errors, typos, and other programming errors found by the compiler:</p>
<p><img src="./images/view_tasks.jpg" alt="Tasks view">

</p>
<p>The <b>Tasks</b> view is part of the core Eclipse platform. For more information about the <b>Tasks</b> view, follow these links in the <cite>Workbench User Guide</cite>: <b>Reference</b>--><b>User interface information</b>--><b>View and Editors</b>--><b>Tasks view</b>.</p>
<p>

The IDE also shows corresponding markers in several other locations:</p>
<ul>
<li><b>C/C++ Projects</b> view: on both the file that contained compile errors and the project
   </li>
<li><b>Outline</b> view: in the method (e.g. <i>main()</i>)
   </li>
<li><b>C/C++ Editor</b>: on the left side, beside the offending line of code.</li>
</ul>

<h3><a name="id43">Jumping to errors</a></h3>

<p>To quickly jump to the source of errors (if the IDE can determine where it is):</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>Tasks</b> view, double-click the error marker <img src="./images/icon_error_obj.gif" alt="Icon: Error marker"> or warning marker <img src="./images/icon_warning_obj.gif" alt="Icon: Warning marker">.
The file opens in the editor area, and the cursor jumps to the offending line.</td></tr>
</table>


<p>

To jump to errors sequentially:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>Click the <b>Jump to next error marker</b> button <img src="./images/icon_next_error_nav.gif" alt="Icon: Jump to next error marker button"> or <b>Jump to previous error marker</b> button <img src="./images/icon_prev_error_nav.gif" alt="Icon: Jump to previous error marker button">.</td></tr>
</table>



<h3><a name="id45">Filtering errors</a></h3>

<p>Depending on the complexity and stage of your program, the IDE can generate an overwhelming number of errors. The IDE lets you customize the <b>Tasks</b> view so you see only the errors you want to see.</p>
<p>

To access the error filtering dialog:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>Tasks</b> view, click the <b>Filter</b> icon <img src="./images/icon_filter_tsk.gif" alt="Icon: Filter button">.
The <b>Filter Tasks</b> dialog appears and lets you adjust the scope of the errors shown in the <b>Tasks</b> view. To see all errors and warnings, check all the boxes in <b>Show items of type</b> and enable <b>On any resource</b>:<p><img src="./images/view_tasks_filter_tasks.jpg" alt="Tasks view; Filter Tasks dialog"></p></td></tr>
</table>



<h3><a name="id47">Setting reminders</a></h3>

<p>The <b>Tasks</b> view lets you create your own tasks. In addition to having the <b>Tasks</b> view automatically list build errors, you can set personal reminders regarding the unfinished function you're writing, the error handling routine you want to check, or <em>anything</em> else.</p>
<p>

To access the <b>New Tasks</b> dialog to add a personal task:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>Tasks</b> view, right-click the tasks pane and select <b>New Task</b>.
A <b>New Tasks</b> dialog appears:<p><img src="./images/view_tasks_new_tasks.jpg" alt="Tasks view; New Tasks dialog"></p></td></tr>
</table>


<p>To remove a personal task:</p>

<table>
<tr><td valign="top"><img src="image-lib/onestep.gif" alt="=&gt;&gt;"></td>
<td>In the <b>Tasks</b> view, right-click the task and select one of <b>Delete</b> or <b>Mark Completed</b>.</td></tr>
</table>



<h2><a name="view_outline">Code synopsis (Outline view)</a></h2>

<p>

The <b>Outline</b> view gives you a structural view of your C/C++ source code:</p>
<p><img src="./images/view_outline.jpg" alt="Outline view"></p>
<p> It shows the elements in the source file in the order they occur, including functions, libraries, and variables. You may also sort the list alphabetically. If you double-click an entry in the <b>Outline</b> view, the <b>C/C++ Editor</b> moves the cursor to the start of the item selected. (For example, to jump to the start of <i>main()</i> in the <b>C/C++ Editor</b>, double-click <i>main()</i> in the <b>Outline</b> view.)</p>

<h2><a name="view_cbuild">Checking your build (C-Build view)</a></h2>

<p>

The IDE displays the output from the <tt>make</tt> utility in the <b>C-Build</b> view:</p>
<p><img src="./images/view_cbuild.jpg" alt="C-Build view">

</p>

<h3><a name="id51">Customizing the C-Build view</a></h3>

<p>You can choose to clear the <b>C-Build</b> view before each new build or let the results of each subsequent build to append to the display. You can have the <b>C-Build</b> view brought to the top when you build. </p>
<p>

To access the <b>C-Build</b> view configurations:</p>
<ol>

<li>From the main menu, select <b>Window</b>--><b>Preferences</b>.
   </li>
<li>In the left pane, select <b>C/C++</b>:<p>  <img src="./images/view_cbuild_configurations.jpg" alt="C-Build view; configurations"></p></li>
</ol>



</body>

</html>

<!--
/**********************************************************************
 * Copyright (c) 2002,2003 QNX Software Systems Ltd. and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors: 
 * QNX Software Systems - Initial API and implementation
***********************************************************************/
-->

Back to the top