HP C/ANSI C Release Notes Version B.11.11.16 Edition 7 HP-UX Systems Manufacturing Part Number: 5991-4869 June 2006 United States © Copyright 2006 Hewlett-Packard Development Company L.P.
Legal Notices The information contained herein is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein. Printed in the United States Confidential computer software. Valid license from HP required for possession, use or copying.
1 HP C/ANSI C Release Notes The information in this document applies to the release of HP C compiler, version B.11.11.16, for the HP-UX 11i/11x operating system.
HP C/ANSI C Release Notes Announcement Announcement HP C is Hewlett-Packard’s version of the C programming language that is implemented on HP Integrity systems. HP C/HP-UX is highly compatible with the C compiler implemented on the HP 9000 Series 300/400 and CCS/C, Corporate Computer Systems C compiler for the HP 3000. This document discusses the following topics: • "New Features in Version B.11.11.16" on page 5 • “New Features in Version B.11.11.14” on page 9 • “New Features in Version B.11.11.
HP C/ANSI C Release Notes What’s in This Version What’s in This Version This section gives an overview of the new features introduced in this version of the HP C compiler. New Features in Version B.11.11.16 HP C compiler version B.11.11.16 supports the following new features: The HP Code Advisor, a source code analysis tool This release introduces a new tool, HP Code Advisor (cadvise) that enables programmers to detect various programming errors in C and C++ source code.
HP C/ANSI C Release Notes What’s in This Version }; void print_val(struct Val *valp){ switch (valp->tp) { case tp_char: printf("%c", valp->c); case tp_int: printf("%d", valp->i); case tp_double: printf("%lf", valp->d); } } As can be seen, the members of an unnamed union can be accessed directly without the need to specify a name for the union.
HP C/ANSI C Release Notes What’s in This Version The following rules govern the flexible array members: • A flexible array member must be the last member of the structure. • The structure must contain at least one named member other than the flexible array member. • A structure containing the flexible array member cannot be a member of another structure or element of an array. • A structure containing, possibly recursively, a flexible array member, cannot be a member of a union.
HP C/ANSI C Release Notes What’s in This Version sizeof(int) * N); ...
HP C/ANSI C Release Notes New Features in Version B.11.11.14 New Features in Version B.11.11.14 HP C compiler version B.11.11.14 supports the following new features: +Onolibcalls=func1[,func2,...] Option Now a list of function names can be specified as arguments to the +Onolibcalls option. The function names can be given after a '=' following the +Onolibcalls option. If multiple function names need to be specified, they can be separated by commas as shown. There can be no intervening spaces/blanks.
HP C/ANSI C Release Notes New Features in Version B.11.11.14 struct S s; get_record(&s); /* function get_record() defined elsewhere */ switch (s.k) { case kind_int: i = s.i; break; case kind_real: d = s.d; break; } return 0; } In the above example, the members i and d of the unnamed union inside the struct S are accessed directly as s.i and s.d, respectively. New option -H to Print Include Files' Hierarchy The -H option enables HPC to print the order and hierarchy of included files to stderr.
HP C/ANSI C Release Notes New Features in Version B.11.11.12 New Features in Version B.11.11.12 HP C compiler version B.11.11.12 supports the following new feature: Debugging of Optimized Code (DOC) in 64-bit Mode Now it is possible to debug code optimized at +O2 in 64-bit (wide) mode using HP C. Use the compilation option -g +O2 +DD64 to achieve this. Earlier, DOC was available only in 32-bit (narrow) mode.
HP C/ANSI C Release Notes New Features in Version B.11.23.02 New Features in Version B.11.23.02 HP C version B.11.23.02 has no changes from version B.11.11.10, except for defect fixes.
HP C/ANSI C Release Notes New Features in Version B.11.11.10 New Features in Version B.11.11.10 HP C compiler version B.11.11.10 supports the following new features: • Function Inlining • +d Option • UNIX95 Feature Function Inlining Now function inlining happens at all optimization levels, by default. Functions that should be inlined by the compiler need to be tagged with the __inline keyword in -Ae mode (inline, in -AC99 mode).
HP C/ANSI C Release Notes New Features in Version B.11.11.08 New Features in Version B.11.11.08 HP C compiler version B.11.11.08 supports the following new features: • restrict Keyword • __typeof__ Operator • __restrict__ Keyword • __volatile__ Keyword • C99 Mode with -AC99 Option • +We[n1,n2,...
HP C/ANSI C Release Notes New Features in Version B.11.11.08 __typeof__ (*x) y[4]; This declares y as an array of pointers to characters: __typeof__(__typeof__(char *)[4]) y; __restrict__ Keyword This keyword can be used to indicate to the optimizer that the associated variable declared with this qualifier will not have aliases (using pointers). This will help in better code optimization. NOTE __restrict__ qualifier can only be used with pointers.
HP C/ANSI C Release Notes New Features in Version B.11.11.08 Non-Constant Initializers for Aggregates Now it is possible to specify non-constant expressions as initializers in the initialization lists of aggregates, such as arrays and structures. The expressions can be any valid C expressions, such as arithmetic expressions involving variables, and even function calls. Earlier it was only possible to specify constant expressions as initializers of aggregates. Example usage: int i, j; /* ...
HP C/ANSI C Release Notes New Features in Version B.11.11.08 +Olit=const places all string literals appearing in a context where const char * is legal, and all const-qualified variables that do not require load-time or run-time initialization in the read-only data section. If +Olit=none is specified, no constants are placed in the read-only data section. +O[no]memory[=malloc] Option This option enables[disables] memory optimizations.
HP C/ANSI C Release Notes New Features in Version B.11.11.08 HPC_DEBUG_COMPAT Environment Variable HP C does not emit debug information for unused objects (structures, unions, and others) anymore with the -g option. For getting the older behavior (emitting debug information for all objects, irrespective of whether they are used in the program or not), the environment variable HPC_DEBUG_COMPAT can be set in the environment along with the -g option in the compilation command line.
HP C/ANSI C Release Notes New Features in Version B.11.11.06 New Features in Version B.11.11.06 HP C compiler version B.11.11.06 supports the following new features: • __FUNCTION__ Predefined Identifier • +ub Option • UTF-16 Character Support • -mt Option __FUNCTION__ Predefined Identifier __FUNCTION__ is a predefined pointer to char defined by the compiler, which points to the name of the function as it appears in the source program. NOTE __FUNCTION__ is same as __func__ of C99.
HP C/ANSI C Release Notes New Features in Version B.11.11.06 #define _UTF16(x) u##x #define UTF16(y) _UTF16(#y) typedef unsigned short utf16_t; utf16_t *utf16_str = UTF16(y); // u”y” int size = sizeof(u’t’); // size of 2 bytes -mt Option The new -mt option enables multi-threading capability without the need to set any other flags, such as -l and -D. HP C compiler sets the appropriate flags as required.
HP C/ANSI C Release Notes Documentation Overview Documentation Overview The HP C/ANSI C compiler and related documentation is available for users of the HP C Developer’s Bundle. This documentation is available both online, and in printed copy. Online documentation is located at http://docs.hp.com, and is viewable using your any of the available web browser.
HP C/ANSI C Release Notes Documentation Overview Contains a detailed discussion about selected C topics. Included are discussions of data type sizes and alignment modes, comparisons between HP C and other languages, and information on 64-bit programming, optimization, threads, and parallel processing. • HP-UX Floating-Point Guide Describes how floating-point arithmetic is implemented and discusses how floating-point behavior affects the programmer.
HP C/ANSI C Release Notes Documentation Overview You may set the CROOTDIR environment variable to set the root directory of the online help source. If CROOTDIR is not set, the URL of the online help will be file:/opt/ansic/html/guide/${LOCALE}/c_index.html ; this is assuming that compiler binaries are located in /opt/ansic/bin.
HP C/ANSI C Release Notes Documentation Overview Describes the changes you need to make to compile, link, and run programs in 64-bit mode. This document is also available online at http://docs.hp.com and in the Postscript file /opt/ansic/newconfig/RelNotes/64bitTrans.bk.ps. • HP PA-RISC Compiler Optimization Technology White Paper Describes the benefits of using optimization. This white paper is available online in the PostScript file: /opt/langtools/newconfig/white_papers/optimize.ps.
HP C/ANSI C Release Notes Installation Information Installation Information This section describes the contents of HP C/ANSI C Developer’s Bundle for HP-UX. This includes the following topics: • Beginning Installation • HP C Developer’s Bundle Contents • Installed Compiler Paths • Transition Links Beginning Installation After loading HP-UX 11.x, you can install your HP C/ANSI C Developer’s Bundle. In addition to the C compiler, it contains the HP-UX Developer’s Toolkit.
HP C/ANSI C Release Notes Installation Information • AudioDevKit: HP Audio Developer Kit (479 Kb) • CDEDevKit: CDE Developer Kit (10,769 Kb) • ImagingDevKit: HP-UX Developer’s Toolkit - Imaging (2,216 Kb) • X11MotifDevKit: HP-UX Developer’s Tool465kit - X11, Motif, and Imake (25,629 Kb) Be aware that, if you install all the packages, they occupy approximately 126 Mb of disk space.
HP C/ANSI C Release Notes Problem Description and Fixes Problem Description and Fixes This section details known defect fixes with accompanying CHART defect database numbers (when available) and workarounds for the HP C/ANSI C compiler. This information is provided by release version number, B.11.11.06. Problems corrected in the final release of the HP C/ANSI C compiler will be referenced in the Software Status Bulletin.
HP C/ANSI C Release Notes Problem Description and Fixes However, you can also insert whitespace to the left of the left operand of ## to more accurately specify the intended left operand. For example, if you use #define foo(f, s...) printf(f, s) Then the macro call foo(“Hello world.\n”); results in the expansion printf(“Hello world.\n”,); (Note the comma ",") causing a syntax error. GNU provides the following workaround for this kind of a situation. If you use: #define foo(f, s...
HP C/ANSI C Release Notes Problem Description and Fixes not expect the same behavior in HP aC++. For the example: for(int i = 0; i < j; i ++) int i; Note the lack of a new block opening for the for statement. The C++ compiler accepts this form, with warnings, but the C compiler does not. The difference in the way the stack is handled causes the difference in behavior. Previously, the C compiler did not emit the source file information for the global typedefs.