System News
   
News about Solaris and Sun Microsystems

Free 2 Week Trial!


June 18, 2007
Article #18215
Volume 112, Issue 3
Section: Software

 


 

New Language Extensions in the Sun Studio 12 C Compiler
SDN Article Provides Overview of C-language Extensions

Sun's Dmitry Mikhailichenko introduces SunTM Studio 12 C compiler's C-language extensions: typeof keyword, statement expressions and block-scope label names, all of which are part of the GNU C-implementation, in a SunSM Developer Network article. He also demonstrates using the new C compiler features for creating generic macros on example of linked-list manipulation-routines.

typeof keyword

Find out what constructs of the "typeof" keyword (a new extension to the C language) are accepted by Sun Studio C compiler, its restrictions of declarations and use in macro definitions. He details the FINDMAX macro and uses it as an example to run code.

Statement Expressions

Mikhailichenko explains the basics, covering similarities and differences that statement expressions have with compound statements and expressions. He references the generalized FINDMAX macro example created in the prior section and rewrites it using statement expressions.

Block-scope Label Names

The new keyword __label__ limits visibility of labels within a block scope. In this section, Mikhailichenko explores declaring local labels and rewrites the FINDMAX macro to display local labels usage.

He then demonstrates implementing a list using typeof and statement expressions. He covers list declaration, inserting and removing an element on a list and list iterations. Three example programs are provided to demonstrate basic operations on a list of int's, a list of structures and constructing a list of lists. [...read more...]

fullsource

Keywords:
Other articles in the Software section of Volume 112, Issue 3:

See all archived articles in the Software section.


From the latest issue:



 


Customized news reports about Sun Microsystems. Just the news you need, none of what you don't.
50,000+ Members. 20,000+ Articles Published since 1998.