LINUX TIPS AND TRICKS --- June 30, 2000

Published by ITworld.com, the IT problem-solving network
http://www.itworld.com/newsletters

*********************************************************************

Get Ready for the New C Standard
by Danny Kalev

The C programming language recently underwent a facelift to fit it to 
the needs of modern hardware architectures, programming environments and 
application domains. The recently approved C99 standard includes several 
new features that C compilers will soon provide (several compilers 
already implement some of these features). In this newsletter, I will 
provide a quick overview of some of the more interesting and innovative 
features.

    * Function-Like Macros With Variable Arguments 
      C99 now supports function-like macros with variable arguments. It 
      uses the ellipsis (...) notation for this purpose, just like 
      ordinary functions with variable arguments. 

    * Inline Function
      C99 borrowed the notion of inline functions from C++. "inline" is 
      now a reserved keyword. You may declare a function inline as a    
      recommendation to the compiler to expand the function inline, 
      thereby avoid the overhead of calling a function.

    * long long Data Type
      long long is a new integral type that occupies a 
      platform-dependent size which is equal to or larger than long. 
      Usually, it's a 64-bit integer. This type has an unsigned 
      counterpart as well.

    * The Identifier __func__ 
      __func__ is a compiler-defined variable that holds the non-mangled 
      name of the lexically enclosing function (i.e., the function in 
      which it is used). It enables you to obtain the name of the 
      current function, similar to the __FILE__ and __DATE__ macros. 
      Note, however, that unlike __DATE__ and __FILE__,  __func__ is a 
      variable, not a macro, because the preprocessor doesn't know about 
      functions.

    * Idempotent Type Qualifiers
      Type qualifiers "const" and "volatile" are idempotent, i.e., if a 
      type qualifier appears several times in a declaration, either 
      directly or through a typedef, it's treated as if it appeared only 
      once. Thus, const const int k=0; is equivalent to const int k=0;. 

    * Restricted Pointers
      A new type qualifier called "restrict" that is applicable to 
      pointer types was added. ("restrict" is a reserved keyword now). 
      In essence, it allows the compiler to employ enhanced 
      optimizations when accessing the data to which the restricted 
      pointer points. For more information on this new feature, see 
      http://www.lysator.liu.se/c/restrict.html.

In addition to the core language changes that I have listed above, the 
C99 standard also defines several new header files and libraries. 

    * Boolean Type
      The new header <stdbool.h> contains typedef names for a 
      standard _Bool type and macros for true and false.

    * Complex Arithmetic
      The new header <complex.h> declares the types _Complex and 
      _Imaginary along with a set of complex arithmetic functions.

    * A Type-Generic Math Library
      The new header <tgmath.h> defines some macros that 
      automatically call the appropriate function from <math.h> or 
      from <complex.h>, depending on their argument's type.

Resources

Scripting with C
http://www.sunworld.com/sunworldonline/swol-04-1999/swol-04-regex.html

Microsoft's new language met with skepticism 
Product delivery, learning curve are both concerns
http://www2.itworld.com/cma/ett_content_article/0,2849,1223_1222,00.html

The safety of scripting 
Cross-language trends in scripting
http://www.sunworld.com/swol-10-1998/f_swol-10-regex.html

************************************************************************

About the author
----------------
Danny Kalev is a system analyst and software engineer with more
than 10 years of experience, specializing in C++ and
object-oriented analysis and design on various platforms including
VMS, DOS, Windows, Unix, and Linux. His technical interests involve
code optimization, networking, and distributed computing. He is
also a member of the ANSI C++ standardization committee and the
author of ANSI/ISO C++ Professional Programmer's Handbook (Que,
1999). Contact him at linuxnl@excite.com.
 
*********************************************************************

CUSTOMER SERVICE

You can subscribe or unsubscribe to any of your e-mail newsletters by 
updating your form at: 
http://www.itworld.com/cgi-bin/w3-msql/newsletters/subcontent12.html?

For subscription changes that cannot be handled via the web, please send 
an email to our customer service dept: support@itworld.com

*********************************************************************

CONTACTS

* For editorial comments, write Andrew Santosusso, Associate Editor, 
Newsletters at: andrew_santosusso@itworld.com
* For advertising information, write Dan Chupka, Account Executive at:
dan_chupka@itworld.com
* For all other inquiries, write Jodie Naze, Product Manager,
Newsletters at: jodie_naze@itworld.com

*********************************************************************

Copyright 2000 ITworld.com, Inc., All Rights Reserved. 

http://www.itworld.com
