Thursday Sep 11, 2008

Software Freedom Day - 2008

Software Freedom Day is Saturday, September 20th. Check it out:

Software Freedom Day

Wednesday Jul 30, 2008

An upcoming change in behavior in the Sun Studio C compiler ...

In an upcoming expresss release of Sun Studio, the C compiler will provide a new option.

    -features=[no%]conststrings

It enables/disables string literal placement in read-only memory. The default for this new option will be -features=conststrings, which replaces the deprecated -xstrconst option. Note that with this change in default, programs attempting to write to a string literal will now fail under the  default compilation mode just as if -xstrconst had been explicitly specified on the command line. Prior to this change, no runtime error would be seen and the contents of the string written to would change. To revert to the old behavior, specify

    -features=no%conststrings

Wednesday Jun 18, 2008

Tutorial on OpenSolaris development is now - FREE

 

To all who might have missed this announcement:

-----

Hi all,

this is to announce a change concerning tutorial
"OpenSolaris: an ultimate development platform?"
by Roman Shaposhnik, [1].  Based on Roman's request
(and thanks to an additional sponsorship from Sun) this
tutorial was converted to a free Sun sponsored event
for anyone who wishes to attended it.  The time
remains the same, see [2] for more details.

The visitors who already registered for Roman's
tutorial and paid for it will get the money returned
back to their account (if they paid using
VISA/MASTERCARD) or in cash during the conference
(if they used direct bank transfer option).

Looking forward to see you at the all,
Lukas

[1] http://www.osdevcon.org/2008/program_detail.html#roman
[2] http://www.osdevcon.org/2008/program.html

Monday Jun 16, 2008

Case ranges in switch statements - a handy extension to C

In standard C, a case label in a switch statement can have only one associated value. Sun Studio (in an upcoming Studio Express Release) will allow an extension found in some compilers known as case ranges.

A case range specifies a range of values to associate with an individual case label. The case range syntax is:

	case low ... high :

A case range behaves exactly as if case labels had been specified for each value in the given 
range from low to high inclusive. (If low and high are equal, the case range specifies only the
one value.) The lower and upper values must conform to the requirements of the C standard. That is, they must be valid integer constant expressions (C standard 6.8.4.2). Case ranges and case 
labels can be freely intermixed, and multiple case ranges can be specified within a switch 
statement.

Example:

enum kind { alpha, number, white, other };
enum kind char_class(char c)
{
    enum kind result;
    switch(c) {
        case 'a' ... 'z':
        case 'A' ... 'Z':
            result = alpha;
            break;
        case '0' ... '9':
            result = number;
            break;
        case ' ':
        case '\\n':
        case '\\t':
        case '\\r':
        case '\\v':
            result = white;
            break;
        default:
            result = other;
            break;
    }
    return result;
}

Note: If an endpoint of a case range is a numeric literal, leave whitespace around the
      ellipsis (...) to avoid one of the dots being treated as a decimal point.

Example:

	case 0...4;   // error
	case 5 ... 9; // ok

Wednesday Jun 04, 2008

Update to a useful feature in the Sun Studio C compiler

Regarding an earlier blog post, where I discussed a new option to the -xcheck flag, there are two new updates coming down the line (most likely in the next Sun Studio Express release). First, the [no%]init_local option to -xcheck will become a regular user option. In other words, it will no longer be necessary to use the -W0 special compiler switch to use this feature.

Second, initialization of local variables will be be extended to include local arrays, structs and unions. Initialization of these types will build on the  existing initializations such that they are natural extensions of what is performed today. For example, if a local array's elements are type float, then  each element will be initialized with the same value used for a simple float local variable. Likewise, for local struct variables, members that are simple types will be initialized as expected (struct members that are themselves structs, arrays or unions, will be initialized using the same methods described here). Unions, however, will be treated just a bit differently than structs or arrays. To maximize the potential that a reference to an uninitialized union will generate a visible error, they will be initialized with the appropriate value for the first declared pointer or float field. If a union contains no members of these types, then a default initialization value will be chosen.

Once again, note that the specific values used for initializations of simple types is always subject to change and can't be relied upon to remain identical between releases. Also, note that by the very nature of what -xcheck=init_local does, memory debuggers most likely will not be able to detect uses of uninitialized local variables in code compiled with this flag.

Feel free to comment about the utility of this feature directly to me or comment via SDN (Sun Developer Network - http://developers.sun.com/) C compiler forums. If you aren't a member, become one and let us know what you think about Sun Studio.

About

dpagan

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today