HP C/aC++ for PA-RISC Software manual Contents

Page 3

Contents

 

HP secure development lifecycle

17

About This Document

18

Intended Audience

18

What’s in This Document

18

Typographical Conventions

19

HP-UX Release Name and Release Identifier

20

Publishing History

20

Related Documents

20

HP Encourages Your Comments

21

1 Getting Started with HP aC++

22

Components of the Compilation System

22

Using the aCC Command

23

Compiling a Simple Program

23

Executing the Program

23

Debugging Programs

23

HP Code Advisor

23

HP WDB Debugger

23

Accessing Online Example Source Files

24

Compiler Command Syntax and Environmental Variables

24

Examples of the aCC Command

24

Compiling and Renaming an Output File

24

Compiling and Debugging

24

Compiling Without Linking

24

Linking Object Files

24

Compiling, Optimizing, and Getting Verbose Information

24

Compiling and Creating a Shared Library

25

Files on the aCC Command Line

25

C++ Source File (.C file)

25

Preprocessed Source Files (.i Files)

25

Assembly Language Source Files (.s Files)

25

Object Files (.o Files)

26

Library Files (.a and .so Files)

26

Configuration Files (.conf Files)

26

Environment Variables

26

aCC_FULL_PATHNAMES Environment Variable

27

aCC_MAXERR Environment Variable

27

CXXOPTS Environment Variable

27

CCLIBDIR Environment Variable

27

CCROOTDIR Environment Variable

28

CXX_MAP_FILE Environment Variable

29

TMPDIR Environment Variable

29

Floating Installation

29

HP aC++

30

HP C

30

Setting up Floating Installation

30

2 Command-Line Options

31

Options to Control Code Generation

32

-c

32

+DOosname

32

+DDdata_model

32

Contents 3

Image 3
Contents HP aC++/HP C A.06.28 Programmers Guide Page Contents +FP Contents Contents Contents Data Alignment Pragmas Pragma Directives and AttributesInitialization and Termination Pragmas Copyright Notice and Identification PragmasContents Preprocessing Directives 119 Standardizing Your Code 138 Using HP aC++ Templates 132Exception Handling 161 Optimizing HP aC++ Programs 156170 Tools and Libraries 175Mixing C++ with Other Languages 188 Distributing Your C++ Products 195 Migrating from HP C++ cfront to HP aC++ 198Strings 194 Arrays Files in Fortran Glossary 223 Index 227 Documentation feedback 221 Diagnostic Messages 222HP secure development lifecycle About This Document Intended AudienceWhat’s in This Document This document uses the following conventions Typographical ConventionsHP-UX 11i Releases Publishing HistoryRelated Documents HP-UX Release Name and Release IdentifierFollowing is a list of documents available with this release HP Encourages Your CommentsOther HP aC++ executable files are Getting Started with HP aC++Components of the Compilation System C89 C99 ecom CtcomDebugging Programs Using the aCC CommandCompiling a Simple Program Executing the ProgramExamples of the aCC Command Compiler Command Syntax and Environmental VariablesPreprocessed Source Files .i Files Files on the aCC Command LineAssembly Language Source Files .s Files ++ Source File .C fileLibrary Files .a and .so Files Configuration Files .conf FilesEnvironment Variables Object Files .o FilesCclibdir Environment Variable ACCFULLPATHNAMES Environment VariableACCMAXERR Environment Variable Cxxopts Environment VariableACC -L/mnt/proj/lib file.o ACC file.o Ccrootdir Environment VariableExport CCROOTDIR=/mnt/CXX2.1 Floating InstallationCxxmapfile Environment Variable Tmpdir Environment VariableHP aC++ Setting up Floating InstallationCommand-Line Options ILP32 Data Model and LP64 Data Model Options to Control Code GenerationACC -c sub.C prog.C ACC +DO11.22 +O3 app.CCompiling in Networked Environments Using +DS to Specify Instruction SchedulingData Alignment and Storage ACC -S prog.CSize and Alignment of HP Compiler Data Types ACC +u1 app.C Debugging OptionsFshort-enums +expandtypesindiag+macrodebug When to use -g, -g0, and -g1Differences Between -g, -g0, and -g1 Options G1 AlgorithmLocal +noobjdebug+pathtrace +pathtrace=kindACC +p file.C Error HandlingNone +pathtrace=globallocal+wn +Wargs+Wcontextlimit +Wv +wperfadvice+We +Weargs+noeh Exception HandlingExtensions to the Language +wsecurity+Onofenvaccess Floating-Point Processing Options+Onocxlimitedrange +decfp FpevalFpevaldec Nofpwidetypes+Onopreservedfpregs +FPmode+Onolibmerrno +OprefetchlatencyHeader File Options ACC -I include file.C Idirs -I- -Idirs +help Online Help Option+inlinelevel num Inlining OptionsLname Library OptionsDynamic Exec+Onolibcalls= Linker OptionsMinshared +nostl+Onodynopt UsymbolUsymbol +Onodynopt+ildrelink Options for Naming the Output FileNative Language Support Option +ildACC -z file.C Handling Null Pointers OptionsCode Optimizing Options Basic Optimization Level Options+O3 +O0+O1 +O2+O4 Additional Optimization Options for Finer Control+O4 ACC +O3 prog.CIpo +nonrv+Onofailsafe +Onoptrstoglobals=list Advanced +Ooptimization Options+Onoaggressive +Onolimit+Onofltacc +Onocrossregionaddressing+Onodatalayout +Onodataprefetch+Onoinitcheck +Ofrequentlycalled+Onoinline +Olit+Ointegeroverflow +Onoopenmp +Olevel+Onolooptransform +Onoloopunroll+Onoprocelim +opts+Onoparminit +Onoparmsoverlap+Orarelycalled +Onosignedpointers+Oshortdata +Ounrollfactor +OtypesafetyProfile-Based Optimization Options +OnostoreorderingAnnotate=structs Parallel Processing OptionsInformation Embedding Options Displaying Optimization InformationRequired if -DPOSIXCSOURCEis used Option Matrix for -mt+tls=staticdynamic +Onoautopar+Ofast Performance Options+wlock Fast+DSmodel +Ofaster+Onotlscallschangetp +nosrcpos+uc Porting Options+sb +ubThis warning can be suppressed by adding an extra cast +w64bit+wdriver +wendianPreprocessor Options DnameRedirecting Output From This Option Examples Maked+Maked +makedProfiling Code Options Uname+profilebucketsize +check=none Runtime Checking Options+check +check=allCompiling with +check=boundspointer +check=boundsarray +check=boundspointerCheck off by any number out-of-bounds access Check off by one out-of-bounds access+check=lock +check=globals+check=malloc +check=thread +check=stackframevariablesnone+check=truncateimplicit +check=truncateexplicitimplicit+check=uninit Ch = intval & 0xff +check=truncateexplicitStandards Related Options AarmAarm Agcc AC89AC99 Ag++AOa and -AOe +legacycpp+legacyv5 +stl=rwnone +std=c89c99c++98c++11gccg++gnu+tru64 +tru64Wc,-ansiforscope,onoff Wc,-koeniglookup,onoffTx,name Subprocesses of the CompilerTx,name More Examples of -tWx,args Passing Options to the Linker with -W Symbol Binding OptionsBdefault BexternBprotecteddata BhiddenBhiddendef BprotectedTemplate Options +instincludesuffixes Trigraph Processing Suppression OptionVerbose Compile and Link Information Process Compiler 94/u 65/s 35/r 37/u 76/s 02/r Concatenating Options ACC -V app.CACC myfile.C -v -g1 ACC myfile.C -vg1 ACC -vg1 myfile.C Initialization and Termination Pragmas Pragma Directives and AttributesCopyright Notice and Identification Pragmas #pragma align N Data Alignment Pragmas#pragma Versionid string #pragma Versionid Software Product, Version 12345.A.01.05Data Alignment Pragmas Template Example Basic ExampleHandling Unaligned Data Implicit Access to Unaligned DataInteraction between pack and unalign pragmas is as follows #pragma unalign Typedef T1 T2Floattrapson Pragma Optimization PragmasOptlevel Pragma Optimize PragmaNoinline Pragma Other Pragmas Diagnostic PragmasExtern Pragma Defaultbinding PragmaBinding Pragma Estimatedfrequency PragmaHpdefinedinternal Pragma Hdrstop PragmaHidden Pragma Hpdefinedexternal PragmaPtrsstronglytyped Pragma POP PragmaPragma once Protected PragmaStdc Fpcontract Pragma #pragma Stdc FLOATCONSTDECIMAL64 on OFF DefaultStdc Cxlimitedrange Pragma Stdc FLOATCONSTDECIMAL64 PragmaStdc Fenvaccess Pragma Unrollfactor PragmaOMP Atomic Pragma OMP Flush Pragma OMP Barrier PragmaOMP Critical Pragma OMP for PragmaOMP Parallel for Pragma OMP Master PragmaOMP Ordered Pragma OMP Parallel PragmaOMP Task Pragma OMP Parallel Sections PragmaOMP Sections Pragma OMP Single PragmaOpenMP Clauses Copyin DefaultCopyprivate SharedAttributes Attribute noreturn Attribute nonexposingAttribute noreturn Attribute nonexposingAttribute format Attribute visibilityAttribute warnunusedresult Usage Guidelines Preprocessing DirectivesOverview of the Preprocessor SyntaxAssertions #assert, #unassert Source File Inclusion #include, #includenextSyntax DescriptionMacros with Parameters Macro Replacement #define, #undef#define mac very very long\ Replacement string ExamplesFollowing illustrates the ## operator Specifying String Literals with the # OperatorConcatenating Tokens with the ## Operator Example#define Arraysize 1000float xARRAYSIZE Using Macros to Define ConstantsOther Macros Var1 isUsing Constants and Inline Functions Instead of Macros Predefined Macros Assertions #assert, #unassertConditional Compilation #if, #ifdef, .. #endif HP aC++ predefines the following predicatesCode that compiles if the expression evaluates to zero Using the #else Directive Using the defined OperatorUsing the #if Directive Using the #ifdef and #ifndef DirectivesLine Control #line Example#line 5 myfile See page 96 for more information on pragmas This macro enables the following non-standard featuresIostream Performance Improvement Pragma Pragma Directive #pragma and Pragma OperatorLine below contains the trigraph sequence ??= Error Directive #errorTrigraph Sequences Examples??=line 5 myfile When this line is compiled it becomesTemplate Processing Using HP aC++ TemplatesInvoking Compile-Time Instantiation Scope and PrecedenceTemplate class Tablechar Explicit InstantiationUsage PerformanceACC -c +instcompiletime a.C ACC -c a.C Command-Line Option InstantiationCompile-Time Instantiation Function TemplateScope Why Use Compile-Time InstantiationPossible Duplicate Symbols in Shared Libraries Possible Duplicate Symbols in Archive LibrariesBuilding an Archive Library with Compile-time Instantiation ++ Template TutorialClass Templates Building an Archive Library with +instauto/+instcloseFunction Templates HP aC++ Keywords Standardizing Your CodeHP aC++ Keywords Bool KeywordDynamiccast Keyword Compile time error message isAbove generates a compile-time error Explicit Keyword Classic example of this problem is an array class Mutable Keyword Connections Across Translation Units Namespace and using KeywordsInt Using- declarations and using- directivesUsing Nx // Where N is a namespace, x is a name in N An Auxiliary Translation UnitPage Class Base Virtual void f Must have a virtual function to Volatile Keyword Wchart Keyword Template KeywordTypename Keyword Overloading new and delete for Arrays Use it as the name of the template C belowDeclare a class as a member of the class template C2 below Example Rangeerror Standard Exception ClassesInvalidargument Exceptions Thrown by the Standard C++ Library Typeinfo ClassFollowing exceptions are thrown by the Standard C++ Library Int before const typeinfo& const Unsupported FunctionalityMemfun1reft Memfunreft Iostream Level 1 Optimization Setting Basic Optimization LevelsOptimizing HP aC++ Programs Requesting OptimizationEnabling Aggressive Optimizations Additional Options for Finer ControlLevel 3 Optimization Level 4 OptimizationLimiting the Size of Optimized Code Removing Compilation Time Limits When OptimizingProfile-Based Optimization Enabling Only Conservative OptimizationsSample.exe input.file1 Sample.exe input.file2 InstrumentationCollecting Data for Profiling Maintaining Profile Data FilesSee Optimization Pragmas page 103 for more information Pragmas That Control OptimizationPerforming Profile-Based Optimization ACC -o sample.exe +Oprofile=use +O3 sample.CException Handling in C++ Exception HandlingFunction Try Block Examples Basic Exception Handling ExampleRogue Wave Standard C++ Library Using ThreadsUsing Locks Debugging Exception Handling Performance ConsiderationsLpthreadThis option applies only to kernel threads Required Command-line OptionsRogue Wave Standard C++ Library Rogue Wave Standard C++ Library 1.2.1 and Tools.h++Cout endl Using -DTHREADSAFE with the cfront Compatible libstreamUsing -DHPACCTHREADSAFERBTREE LimitationsPthreads Posix Threads Exception HandlingACC -mt prog.c Parallel Programming Using OpenMP Function ScopingOpenMP Implementation OpenMP Header File OpenMP LibraryOpenMP APIs are defined in the library libomp Where, kind is either of of static, dynamic, or guided +Onoopenmp Command Line OptionEnvironment Variables in OpenMP Openmp MacroExport OMPNESTED=value Setenv Ompnested value Runtime Library Functions in OpenMPExecution Environment Functions Export OMPDYNAMIC=value Setenv Ompdynamic valueOmpgetthreadnum OmpsetnumthreadsOmpgetnumthreads OmpgetmaxthreadsOmpsetnested Lock FunctionsOmpsetdynamic OmpgetdynamicOmpunsetlock and ompunsetnestlock Ompinitlock and ompinitnestlockOmpdestroylock and ompdestroynestlock Ompsetlock and ompsetnestlockOmpgetwtick Timing FunctionsOmptestlock and omptestnestlock Functions OmpgetwtimeLocale directive for lex HP Specific Features of lex and yaccCreating and Using Libraries Tools and LibrariesIntroduction Introduction to Using the Standard C++ LibraryHP aC++ Libraries Standard C++ LibraryNon-Object-Oriented Design of the Standard C++ Library Differences between Standard C++ Library and Other LibrariesIncompatibilities Between the Library and the Standard Standard C++ Library ReferenceIOStream Library ACC -DHPACCUSINGMULTIPLIESINFUNCTIONAL test.cTools.h++ Library HP aC++ Runtime Support LibrarySpecifying Other Libraries Creating and Using Shared LibrariesLinking to C++ Libraries Linking with Shared or Archive LibrariesLinking Archive or Shared Libraries Using a Shared LibraryExample of Creating and Using a Shared Library Creating a Shared LibraryAdvanced Shared Library Features Forcing the Export of Symbols in mainUpdating a Shared Library Linker Options to Manage Shared Libraries Binding TimesSide Effects of C++ Shared Libraries Routines and Options to Manage C++ Shared LibrariesAllocation Policies for Containers Standard HP-UX Libraries and Header FilesFor a string type For -AA Standard LibraryHP aC++ Executable Files HP aC++ File LocationsHP aC++ Runtime Libraries and Header Files Usr/lib/hpux##/libCsup.soUsr/lib/hpux##/libCsup11.so ISO C++11 standard compliant Mixing C++ with Other Languages Calling Other LanguagesData Compatibility between C and C++ Examples of extern C Using the extern C Linkage SpecificationHP aC++ Calling HP C Syntax of extern CDifferences in Argument Passing Conventions Main FunctionExamples HP aC++ Calling HP C HP C Calling HP aC++ Running the ExampleEnter the nameJoann Joann has a balance Compiling and Running the Sample Programs To compile the example, run the following commandsExample of Reference Variables as Arguments Using Reference Variables to Pass ArgumentsCalling HP Fortran 90 from HP aC++ Function Naming ConventionsFiles in Fortran Using extern C LinkageStrings ArraysApplications that use HP aC++ Shared Libraries Distributing Your C++ ProductsInstalling your Application Linking Your HP aC++ Libraries with Other LanguagesHP aC++ Files You May Distribute Terms for Distribution of HP aC++ Files CC +p cfrontfile.C Migrating from HP C++ cfront to HP aC++General Guidelines for Migration Getting Started with MigrationExplicit Loading and Unloading of Shared Libraries Command-Line DifferencesNew Command-Line Options Writing Code for both CompilersDescribes obsolete command-line options for HP aC++ Obsolete Command-Line OptionsPtv Changed Command-Line OptionsSee Debugging Options page 35 for complete information Migration Considerations when DebuggingMigration Considerations when Using Exception Handling Exception Handling is the DefaultMemory Allocation Failure and operator new Possible Differences when Exiting a Signal HandlerCalling unexpected Differences in setjmp/longjmp BehaviorThrowing an Object having an Ambiguous Base Class Unreachable catch ClausesStandards Based Libraries Migration Considerations when Using LibrariesMan 3s filebuf HP C++ cfront Compatibility LibrariesFstream3C++ iostream and streambuf specialized to files Manip3C++ iostream manipulatorsReplace #include with complex Migration Considerations Related to PreprocessingHP C++ cfront Complex Library Not Supported HP C++ cfront Task Library Not SupportedImplicit Typing of Character String Literals Migration Considerations Related to StandardizationObsolete Preprocessor Options Changes in C++ SemanticsExecution Order of Static Constructors in Shared Libraries Overload Resolution Ambiguity of Subscripting OperatorChanges in C++ Syntax More Frequent Inlining of Inline CodeExplicit int Declaration WC,-ansiforscope,on For Statement, New Scoping RulesStruct as Template Type Parameter is Permitted Equivalent, valid HP aC++ code followsOverload not a Keyword This code compiles without error with HP aC++Base Template Class Reference Syntax Change Tokens after #endifDangling Comma in enum Static Member Definition RequiredDeclaring friend Classes Ambiguous Function or Object Declaration Using in Class DefinitionsIncorrect Syntax for Calls to operator new Duplicate Formal Argument NamesReference Initialization Overloaded Operations ++Parentheses in Static Member Initialization List Using operator new to Allocate ArraysOn HP aC++, the following error is generated Compiling this code HP aC++ generates the following errorNon-constant Reference Initialization Qualified-id Required in Static Member Initialization ListCA a Migration Considerations when Using TemplatesVerbose Template Processing Information Digraph White Space SeparatorsConverting Directed Mode to Explicit Instantiation Common Template Migration Syntax ChangesCfront Implicit Include Convention Documentation feedback Diagnostic Messages AC++ Message CatalogFrequently Encountered Messages Aggressive GlossaryInternational Standard defines only synchronous exceptions See template Glossary Index SymbolsCrootdir FLOATTRAPSON, 103 FREQUENTLYCALLED, 106 HDRSTOP, 107 Hidden Index
Related manuals
Manual 15 pages 49.53 Kb