Cross-platform development in C++: building Mac OS X, Linux, and Windows applications 9780321246424, 032124642X

Cross-Platform Development in C++is the definitive guide to developing portable C/C++ application code that will run nat

666 67 4MB

English Pages xxv, 547 pages: illustrations; 24 cm [577] Year 2007;2008

Report DMCA / Copyright

DOWNLOAD FILE

Cross-platform development in C++: building Mac OS X, Linux, and Windows applications
 9780321246424, 032124642X

Table of contents :
Cover......Page 1
Contents......Page 8
Foreword......Page 14
Preface......Page 16
Acknowledgments......Page 24
About the Author......Page 26
Introduction......Page 28
Areas That Can Affect Software Portability......Page 30
The Role of Abstraction......Page 37
Item 1: Make All of Your Platforms a Priority......Page 44
Item 2: Code from a Common Codebase......Page 49
Platform Factory Implementations......Page 56
Implementation Classes......Page 58
Platform-Specific ProcessesImpl Classes......Page 59
Creating the Instance Hierarchy......Page 69
Organizing the Project in CVS or SVN......Page 72
Makefiles and Building the Code......Page 76
Item 3: Require Developers to Compile Their Code with Different Compilers......Page 79
Item 4: Require Developers to Build Their Code on Multiple Platforms......Page 83
Item 5: Test Builds on Each Supported Platform......Page 87
Item 6: Pay Attention to Compiler Warnings......Page 88
GNU Flags......Page 89
Microsoft Visual C++......Page 90
2 Build System/Toolchain......Page 92
Item 7: Use Whatever Compiler Makes the Most Sense for a Platform......Page 93
Item 8: Use Native IDEs When Appropriate......Page 94
Item 9: Install and Use Cygwin on Windows......Page 98
Item 10: Use a Cross-Platform Make System......Page 103
Make......Page 104
Building on Windows......Page 108
Autoconf/Automake......Page 114
Installing on Windows......Page 118
Using Imake, an Example......Page 120
Imakefiles......Page 121
Building a Complete Program from Multiple Sources......Page 122
Overriding Defaults with site.def......Page 126
Eliminating #ifdefs in Code......Page 128
Files Used by Imake......Page 134
Building Projects with Subdirectories......Page 135
Building Debug......Page 157
3 Software Configuration Management......Page 158
Item 11: Use a Cross-Platform Bug Reporting and Tracking System......Page 159
Bugzilla......Page 160
Item 12: Set Up a Tinderbox......Page 167
Item 13: Use CVS or Subversion to Manage Source Code......Page 174
Setting Up and Using CVS......Page 179
Item 14: Use Patch......Page 184
An Example......Page 185
Patch Options......Page 188
Dealing with Rejects......Page 189
Patch and Cross-Platform Development......Page 190
Item 15: Provide Support for Native Installers......Page 192
XPInstall......Page 193
Platform Installs......Page 197
5 Operating System Interfaces and Libraries......Page 248
POSIX......Page 249
Support for POSIX, SVID, XPG, and BSD......Page 253
Using Standards Support in GCC......Page 254
Microsoft Runtime Library Support for POSIX......Page 258
Using GCC on Microsoft Windows......Page 261
Deciding Which Standards to Support......Page 267
Why NSPR?......Page 269
NSPR Basics......Page 272
Threads......Page 276
Additional NSPR Functionality......Page 287
6 Miscellaneous Portability Topics......Page 300
Item 18: Take Care When Using Floating Point......Page 301
Don’t Serialize Floating-Point Values as Binary......Page 303
Equality......Page 304
Item 19: Be Explicit Regarding the Sign of Char Types......Page 305
Item 20: Avoid the Serialization of Binary Data......Page 307
Size of Integer Types......Page 320
NSPR and Types......Page 323
Sizes and Efficiency......Page 324
Integer Conversions......Page 325
Struct Alignment and Ordering......Page 326
7 User Interfaces......Page 330
Item 22: Separate the User Interface from the Model......Page 331
Separating the User Interface and Application Logic with Model/View......Page 332
Using Publish/Subscribe to Communicate between the View and the Model......Page 345
Summary......Page 349
Issues Affecting Portable Cross-Platform GUI Development......Page 350
Choosing a GUI Strategy......Page 352
8 wxWidgets......Page 356
wxWidgets......Page 358
Installing wxWidgets......Page 359
A Simple Example: Hello wxWidgets......Page 362
Creating the Application User Interface......Page 364
Building wxWidgets Applications......Page 372
Controls and Events......Page 376
Container Widgets......Page 390
Dialogs......Page 419
Composite Widgets......Page 431
Internationalization and Localization......Page 437
9 Developing a Cross-Platform GUI Toolkit in C++......Page 454
What is XUL?......Page 455
HTML......Page 456
Scripting Language......Page 460
The Document Object Model......Page 461
Style Systems......Page 464
XUL......Page 465
Boxes......Page 466
Toolbars......Page 467
Controls......Page 468
Programming with XUL......Page 469
Adding Logic to the UI with JavaScript......Page 470
Interfacing JavaScript and C/C++ Code with XPCOM and XPConnect......Page 471
Trixul......Page 473
Widget Support in Trixul......Page 474
Basic Operation of Trixul......Page 475
Widgets......Page 476
Implementation Classes......Page 479
Creating Widget Implementation Objects......Page 486
Widget Factories......Page 490
Application Main Loop......Page 493
Steps Taken by Trixul to Create a User Interface......Page 498
Documents, Elements, and the DOM......Page 499
Widget Creation......Page 502
Layout......Page 504
Scrolled Windows and Layout......Page 511
Integration with JavaScript......Page 512
Integrating with C++ Components......Page 523
A......Page 546
B......Page 547
C......Page 548
D......Page 551
E......Page 552
F......Page 553
G......Page 556
I......Page 557
J......Page 558
L......Page 559
M......Page 560
N......Page 562
P......Page 563
S......Page 566
T......Page 569
V......Page 570
W......Page 571
X-Y-Z......Page 574

Polecaj historie