HP C/aC++ for PA-RISC Software manual Options to Control Code Generation, ACC -c sub.C prog.C

Page 32

Options to Control Code Generation

The following options allow you to control the kind of code that the compiler generates:

-c

+DOosname

+DDdata_model

+DSmodel

-S

-c

You can use the -coption to compile one or more source files without entering the linking phase.

When compiled, the compiler produces an object file (a file ending with .o) for each source file (a file ending with .c, .C, .s, or .i). Note that you must link object files before they can be executed.

Example:

aCC -c sub.C prog.C

In this example, the compiler compiles sub.C and prog.C and puts the relocatable object code in the files, sub.o and prog.o, respectively.

+DOosname

The +DOosname option sets the target operating system for the compiler, and is intended for enabling optimizations that are not backward compatible.

For instance, the 11.23 compiler introduces new optimized math library functions that require library support not available in prior operating systems. +DO can be used at any level of optimization. The default value for osname is the operating system version on which the compiler is invoked.

The syntax for this option is +DOosname, where osname is either 11.20, 11.22 or 11.23.

Example:

The following example generates code for the HP-UX 11.22 (or later) operating system. Binary incompatible features introduced in later OS versions are inhibited.

aCC +DO11.22 +O3 app.C

+DDdata_model

The +DDdata_model option specifies the data model for the compiler.

data_model can be one of the following:

32 (This value generates ILP32 code and is the default.)

64 (This value generates LP64 code.)

This option specifies the data model for the compiler. Table 2 lists the differences between the two data models.

Table 2 ILP32 Data Model and LP64 Data Model

ILP32 Data Model

The size of an int, long, or pointer data type is 32-bits.

The preprocessor predefined macro _ILP32 is defined.

LP64 Data Model

The size of an int data type is 32-bits. The size of a long or pointer data type is 64-bits.

The preprocessor predefined macros__LP64__ and _LP64 are defined.

32 Command-Line Options

Image 32
Contents HP aC++/HP C A.06.28 Programmers Guide Page Contents +FP Contents Contents Contents Pragma Directives and Attributes Initialization and Termination PragmasCopyright Notice and Identification Pragmas Data Alignment PragmasContents Preprocessing Directives 119 Using HP aC++ Templates 132 Standardizing Your Code 138Optimizing HP aC++ Programs 156 Exception Handling 161Tools and Libraries 175 170Mixing C++ with Other Languages 188 Strings 194 Arrays Files in Fortran Distributing Your C++ Products 195Migrating from HP C++ cfront to HP aC++ 198 Documentation feedback 221 Diagnostic Messages 222 Glossary 223 Index 227HP secure development lifecycle What’s in This Document About This DocumentIntended Audience Typographical Conventions This document uses the following conventionsPublishing History Related DocumentsHP-UX Release Name and Release Identifier HP-UX 11i ReleasesHP Encourages Your Comments Following is a list of documents available with this releaseGetting Started with HP aC++ Components of the Compilation SystemC89 C99 ecom Ctcom Other HP aC++ executable files areUsing the aCC Command Compiling a Simple ProgramExecuting the Program Debugging ProgramsCompiler Command Syntax and Environmental Variables Examples of the aCC CommandFiles on the aCC Command Line Assembly Language Source Files .s Files++ Source File .C file Preprocessed Source Files .i FilesConfiguration Files .conf Files Environment VariablesObject Files .o Files Library Files .a and .so FilesACCFULLPATHNAMES Environment Variable ACCMAXERR Environment VariableCxxopts Environment Variable Cclibdir Environment VariableCcrootdir Environment Variable ACC -L/mnt/proj/lib file.o ACC file.oFloating Installation Cxxmapfile Environment VariableTmpdir Environment Variable Export CCROOTDIR=/mnt/CXX2.1Setting up Floating Installation HP aC++Command-Line Options Options to Control Code Generation ACC -c sub.C prog.CACC +DO11.22 +O3 app.C ILP32 Data Model and LP64 Data ModelUsing +DS to Specify Instruction Scheduling Compiling in Networked EnvironmentsSize and Alignment of HP Compiler Data Types Data Alignment and StorageACC -S prog.C Debugging Options Fshort-enums+expandtypesindiag ACC +u1 app.CWhen to use -g, -g0, and -g1 Differences Between -g, -g0, and -g1 OptionsG1 Algorithm +macrodebug+noobjdebug +pathtrace+pathtrace=kind LocalError Handling None+pathtrace=globallocal ACC +p file.C+Wcontextlimit +wn+Wargs +wperfadvice +We+Weargs +WvException Handling Extensions to the Language+wsecurity +noeh+Onocxlimitedrange +OnofenvaccessFloating-Point Processing Options Fpeval FpevaldecNofpwidetypes +decfp+FPmode +Onolibmerrno+Oprefetchlatency +OnopreservedfpregsHeader File Options ACC -I include file.C Idirs -I- -Idirs Online Help Option +helpInlining Options +inlinelevel numLibrary Options DynamicExec LnameLinker Options Minshared+nostl +Onolibcalls=Usymbol Usymbol+Onodynopt +OnodynoptOptions for Naming the Output File Native Language Support Option+ild +ildrelinkHandling Null Pointers Options Code Optimizing OptionsBasic Optimization Level Options ACC -z file.C+O0 +O1+O2 +O3Additional Optimization Options for Finer Control +O4ACC +O3 prog.C +O4+Onofailsafe Ipo+nonrv Advanced +Ooptimization Options +Onoaggressive+Onolimit +Onoptrstoglobals=list+Onocrossregionaddressing +Onodatalayout+Onodataprefetch +Onofltacc+Ofrequentlycalled +Onoinitcheck+Ointegeroverflow +Onoinline+Olit +Olevel +Onolooptransform+Onoloopunroll +Onoopenmp+opts +Onoparminit+Onoparmsoverlap +Onoprocelim+Oshortdata +Orarelycalled+Onosignedpointers +Otypesafety Profile-Based Optimization Options+Onostoreordering +OunrollfactorParallel Processing Options Information Embedding OptionsDisplaying Optimization Information Annotate=structsOption Matrix for -mt Required if -DPOSIXCSOURCEis used+Onoautopar +tls=staticdynamicPerformance Options +wlockFast +Ofast+Ofaster +Onotlscallschangetp+nosrcpos +DSmodelPorting Options +sb+ub +uc+w64bit +wdriver+wendian This warning can be suppressed by adding an extra castRedirecting Output From This Option Preprocessor OptionsDname Maked +Maked+maked Examples+profilebucketsize Profiling Code OptionsUname Runtime Checking Options +check+check=all +check=none+check=boundsarray +check=boundspointer Compiling with +check=boundspointerCheck off by one out-of-bounds access Check off by any number out-of-bounds access+check=globals +check=lock+check=malloc +check=stackframevariablesnone +check=thread+check=truncateexplicitimplicit +check=uninitCh = intval & 0xff +check=truncateexplicit +check=truncateimplicitAarm Standards Related OptionsAarm AC89 AC99Ag++ Agcc+legacyv5 AOa and -AOe+legacycpp +std=c89c99c++98c++11gccg++gnu +stl=rwnone+tru64 Wc,-ansiforscope,onoffWc,-koeniglookup,onoff +tru64Subprocesses of the Compiler Tx,nameMore Examples of -t Tx,nameWx,args Symbol Binding Options BdefaultBextern Passing Options to the Linker with -WBhidden BhiddendefBprotected BprotecteddataTemplate Options Trigraph Processing Suppression Option +instincludesuffixesVerbose Compile and Link Information Process Compiler 94/u 65/s 35/r 37/u 76/s 02/r ACC myfile.C -v -g1 ACC myfile.C -vg1 ACC -vg1 myfile.C Concatenating OptionsACC -V app.C Pragma Directives and Attributes Initialization and Termination PragmasCopyright Notice and Identification Pragmas Data Alignment Pragmas #pragma Versionid string#pragma Versionid Software Product, Version 12345.A.01.05 #pragma align NData Alignment Pragmas Basic Example Template ExampleImplicit Access to Unaligned Data Handling Unaligned Data#pragma unalign Typedef T1 T2 Interaction between pack and unalign pragmas is as followsOptimization Pragmas Optlevel PragmaOptimize Pragma Floattrapson PragmaNoinline Pragma Diagnostic Pragmas Other PragmasDefaultbinding Pragma Binding PragmaEstimatedfrequency Pragma Extern PragmaHdrstop Pragma Hidden PragmaHpdefinedexternal Pragma Hpdefinedinternal PragmaPOP Pragma Pragma onceProtected Pragma Ptrsstronglytyped Pragma#pragma Stdc FLOATCONSTDECIMAL64 on OFF Default Stdc Cxlimitedrange PragmaStdc FLOATCONSTDECIMAL64 Pragma Stdc Fpcontract PragmaOMP Atomic Pragma Stdc Fenvaccess PragmaUnrollfactor Pragma OMP Barrier Pragma OMP Critical PragmaOMP for Pragma OMP Flush PragmaOMP Master Pragma OMP Ordered PragmaOMP Parallel Pragma OMP Parallel for PragmaOMP Parallel Sections Pragma OMP Sections PragmaOMP Single Pragma OMP Task PragmaOpenMP Clauses Default CopyprivateShared CopyinAttributes Attribute nonexposing Attribute noreturnAttribute nonexposing Attribute noreturnAttribute warnunusedresult Attribute formatAttribute visibility Preprocessing Directives Overview of the PreprocessorSyntax Usage GuidelinesSource File Inclusion #include, #includenext SyntaxDescription Assertions #assert, #unassertMacro Replacement #define, #undef #define mac very very long\ Replacement stringExamples Macros with ParametersSpecifying String Literals with the # Operator Concatenating Tokens with the ## OperatorExample Following illustrates the ## operatorUsing Macros to Define Constants Other MacrosVar1 is #define Arraysize 1000float xARRAYSIZEUsing Constants and Inline Functions Instead of Macros Assertions #assert, #unassert Predefined MacrosCode that compiles if the expression evaluates to zero Conditional Compilation #if, #ifdef, .. #endifHP aC++ predefines the following predicates Using the defined Operator Using the #if DirectiveUsing the #ifdef and #ifndef Directives Using the #else Directive#line 5 myfile Line Control #lineExample This macro enables the following non-standard features Iostream Performance Improvement PragmaPragma Directive #pragma and Pragma Operator See page 96 for more information on pragmasError Directive #error Trigraph SequencesExamples Line below contains the trigraph sequence ??=When this line is compiled it becomes ??=line 5 myfileUsing HP aC++ Templates Invoking Compile-Time InstantiationScope and Precedence Template ProcessingExplicit Instantiation UsagePerformance Template class TablecharCommand-Line Option Instantiation Compile-Time InstantiationFunction Template ACC -c +instcompiletime a.C ACC -c a.CWhy Use Compile-Time Instantiation Possible Duplicate Symbols in Shared LibrariesPossible Duplicate Symbols in Archive Libraries Scope++ Template Tutorial Class TemplatesBuilding an Archive Library with +instauto/+instclose Building an Archive Library with Compile-time InstantiationFunction Templates Standardizing Your Code HP aC++ KeywordsBool Keyword HP aC++ KeywordsCompile time error message is Dynamiccast KeywordAbove generates a compile-time error Explicit Keyword Classic example of this problem is an array class Mutable Keyword Namespace and using Keywords Connections Across Translation UnitsUsing- declarations and using- directives Using Nx // Where N is a namespace, x is a name in NAn Auxiliary Translation Unit IntPage Class Base Virtual void f Must have a virtual function to Volatile Keyword Typename Keyword Wchart KeywordTemplate Keyword Declare a class as a member of the class template C2 below Overloading new and delete for ArraysUse it as the name of the template C below Example Invalidargument RangeerrorStandard Exception Classes Following exceptions are thrown by the Standard C++ Library Exceptions Thrown by the Standard C++ LibraryTypeinfo Class Unsupported Functionality Int before const typeinfo& constMemfun1reft Memfunreft Iostream Setting Basic Optimization Levels Optimizing HP aC++ ProgramsRequesting Optimization Level 1 OptimizationAdditional Options for Finer Control Level 3 OptimizationLevel 4 Optimization Enabling Aggressive OptimizationsRemoving Compilation Time Limits When Optimizing Profile-Based OptimizationEnabling Only Conservative Optimizations Limiting the Size of Optimized CodeInstrumentation Collecting Data for ProfilingMaintaining Profile Data Files Sample.exe input.file1 Sample.exe input.file2Pragmas That Control Optimization Performing Profile-Based OptimizationACC -o sample.exe +Oprofile=use +O3 sample.C See Optimization Pragmas page 103 for more informationException Handling Exception Handling in C++Basic Exception Handling Example Function Try Block ExamplesUsing Threads Using LocksDebugging Exception Handling Performance Considerations Rogue Wave Standard C++ LibraryRequired Command-line Options Rogue Wave Standard C++ LibraryRogue Wave Standard C++ Library 1.2.1 and Tools.h++ LpthreadThis option applies only to kernel threadsUsing -DTHREADSAFE with the cfront Compatible libstream Using -DHPACCTHREADSAFERBTREELimitations Cout endlACC -mt prog.c Pthreads Posix ThreadsException Handling OpenMP Implementation Parallel Programming Using OpenMPFunction Scoping OpenMP APIs are defined in the library libomp OpenMP Header FileOpenMP Library +Onoopenmp Command Line Option Environment Variables in OpenMPOpenmp Macro Where, kind is either of of static, dynamic, or guidedRuntime Library Functions in OpenMP Execution Environment FunctionsExport OMPDYNAMIC=value Setenv Ompdynamic value Export OMPNESTED=value Setenv Ompnested valueOmpsetnumthreads OmpgetnumthreadsOmpgetmaxthreads OmpgetthreadnumLock Functions OmpsetdynamicOmpgetdynamic OmpsetnestedOmpinitlock and ompinitnestlock Ompdestroylock and ompdestroynestlockOmpsetlock and ompsetnestlock Ompunsetlock and ompunsetnestlockTiming Functions Omptestlock and omptestnestlock FunctionsOmpgetwtime OmpgetwtickHP Specific Features of lex and yacc Creating and Using LibrariesTools and Libraries Locale directive for lexIntroduction to Using the Standard C++ Library HP aC++ LibrariesStandard C++ Library IntroductionDifferences between Standard C++ Library and Other Libraries Non-Object-Oriented Design of the Standard C++ LibraryStandard C++ Library Reference Incompatibilities Between the Library and the StandardACC -DHPACCUSINGMULTIPLIESINFUNCTIONAL test.c Tools.h++ LibraryHP aC++ Runtime Support Library IOStream LibraryCreating and Using Shared Libraries Linking to C++ LibrariesLinking with Shared or Archive Libraries Specifying Other LibrariesUsing a Shared Library Example of Creating and Using a Shared LibraryCreating a Shared Library Linking Archive or Shared LibrariesUpdating a Shared Library Advanced Shared Library FeaturesForcing the Export of Symbols in main Binding Times Side Effects of C++ Shared LibrariesRoutines and Options to Manage C++ Shared Libraries Linker Options to Manage Shared LibrariesStandard HP-UX Libraries and Header Files Allocation Policies for ContainersFor -AA Standard Library For a string typeHP aC++ File Locations HP aC++ Executable FilesUsr/lib/hpux##/libCsup11.so ISO C++11 standard compliant HP aC++ Runtime Libraries and Header FilesUsr/lib/hpux##/libCsup.so Data Compatibility between C and C++ Mixing C++ with Other LanguagesCalling Other Languages Using the extern C Linkage Specification HP aC++ Calling HP CSyntax of extern C Examples of extern CExamples HP aC++ Calling HP C Differences in Argument Passing ConventionsMain Function Enter the nameJoann Joann has a balance HP C Calling HP aC++Running the Example To compile the example, run the following commands Compiling and Running the Sample ProgramsUsing Reference Variables to Pass Arguments Calling HP Fortran 90 from HP aC++Function Naming Conventions Example of Reference Variables as ArgumentsUsing extern C Linkage StringsArrays Files in FortranDistributing Your C++ Products Applications that use HP aC++ Shared LibrariesHP aC++ Files You May Distribute Installing your ApplicationLinking Your HP aC++ Libraries with Other Languages Terms for Distribution of HP aC++ Files Migrating from HP C++ cfront to HP aC++ General Guidelines for MigrationGetting Started with Migration CC +p cfrontfile.CCommand-Line Differences New Command-Line OptionsWriting Code for both Compilers Explicit Loading and Unloading of Shared LibrariesObsolete Command-Line Options Describes obsolete command-line options for HP aC++Changed Command-Line Options PtvMigration Considerations when Debugging Migration Considerations when Using Exception HandlingException Handling is the Default See Debugging Options page 35 for complete informationPossible Differences when Exiting a Signal Handler Memory Allocation Failure and operator newDifferences in setjmp/longjmp Behavior Calling unexpectedUnreachable catch Clauses Throwing an Object having an Ambiguous Base ClassMigration Considerations when Using Libraries Standards Based LibrariesHP C++ cfront Compatibility Libraries Fstream3C++ iostream and streambuf specialized to filesManip3C++ iostream manipulators Man 3s filebufMigration Considerations Related to Preprocessing HP C++ cfront Complex Library Not SupportedHP C++ cfront Task Library Not Supported Replace #include with complexMigration Considerations Related to Standardization Obsolete Preprocessor OptionsChanges in C++ Semantics Implicit Typing of Character String LiteralsOverload Resolution Ambiguity of Subscripting Operator Execution Order of Static Constructors in Shared LibrariesExplicit int Declaration Changes in C++ SyntaxMore Frequent Inlining of Inline Code For Statement, New Scoping Rules Struct as Template Type Parameter is PermittedEquivalent, valid HP aC++ code follows WC,-ansiforscope,onThis code compiles without error with HP aC++ Base Template Class Reference Syntax ChangeTokens after #endif Overload not a KeywordDeclaring friend Classes Dangling Comma in enumStatic Member Definition Required Using in Class Definitions Incorrect Syntax for Calls to operator newDuplicate Formal Argument Names Ambiguous Function or Object DeclarationOverloaded Operations ++ Reference InitializationUsing operator new to Allocate Arrays On HP aC++, the following error is generatedCompiling this code HP aC++ generates the following error Parentheses in Static Member Initialization ListQualified-id Required in Static Member Initialization List Non-constant Reference InitializationMigration Considerations when Using Templates Verbose Template Processing InformationDigraph White Space Separators CA aCfront Implicit Include Convention Converting Directed Mode to Explicit InstantiationCommon Template Migration Syntax Changes Documentation feedback Frequently Encountered Messages Diagnostic MessagesAC++ Message Catalog Glossary AggressiveInternational Standard defines only synchronous exceptions See template Glossary Symbols IndexCrootdir FLOATTRAPSON, 103 FREQUENTLYCALLED, 106 HDRSTOP, 107 Hidden Index
Related manuals
Manual 15 pages 49.53 Kb