Wednesday, July 23, 2008

screen goes black when use vesafb

When I use vesafb and set vga=xxx as kernel option to change the resolution, the screen goes blank at boot time. I know the system is still booting, nothing is wrong except the screen.

I finally found the solution. I appears the framebuffer module is not loaded with the kernel.

The walkthough is to edit /etc/modules.autoload.d/kernel-2.6   (in Gentoo, other distros may have different path) to add these two lines:

fbcon
vesafb

...
Read More

Saturday, July 12, 2008

升级x11-misc/shared-mime-info-0.40后mime数据出问题

升级x11-misc/shared-mime-info-0.40后打不开pdf、zip等文件,所有格式均识别为mime/plain-text。

Gentoo Bug #228885

解决办法为:

$ update-mime-database ~/.local/share/mime/
# update-mime-database /usr/local/share/mime/

...
Read More

Thursday, July 10, 2008

关于Sql Server Compact程序运行结束后更改丢失的问题

最近用Linq to SQL + Sql Server Compact 3.5写东西

发现往数据库里加东西以后,程序运行时是有效的,但是重编译工程后这些更改又丢失了。

后来得知,这是因为数据库文件默认的生成方式是“总是复制”(always copy),这样每次build都会把空的数据库文件拷到output目录。改成“copy if newer”就好了。

...
Read More

Tuesday, July 1, 2008

[转]Linux之父炮轰C++:糟糕程序员的垃圾语言

...
Read More

C99的新特性

C99的语法还是很爽的,单行注释、bool、随处声明变量,都很必要。

最近心血来潮想查查C99的全部新特性,发现还有很多我不知道的。

以下是C99之于C89的新特性,摘自http://www.kuro5hin.org/?op=displaystory;sid=2001/2/23/194544/139

Interesting New Features

A list of features that should[0] have made it into the C99 standard is available on Thomas Wolf's webpage. Listed below are the changes that most developers would notice or care about at first use. 
Increased identifier size limits: specifically 63 significant initial characters in an internal identifier or macro name, 31 significant initial characters in an external identifier, and 4095 characters in a logical source line. These values were 31, 6, and 509, respectively, in C89. 

The small identifier size is the reason so many ANSI functions had terse names (strcpy, strstr, strchr, etc) since the standard only guaranteed that the first six characters would be used to uniquely identify the functions. 

C++ style/line comments: The characters '//' can now be used to delineate a line of commented text, just like in C++. 

Macros take variable arguments denoted by elipsees: Function-like macros will accept variable arguments denoted by using the ellipsis (...) notation. For replacement, the variable arguments (including the separating commas) are "collected" into one single extra argument that can be referenced as __VA_ARGS__ within the macro's replacement list. 

Inline functions: The C language now supports the inline keyword which allows functions to be defined as inline, which is a hint to the compiler that invocations of such functions can be replaced with inline code expansions rather than actual function calls.

Restricted pointers: The C language now supports the restrict keyword which allows pointers to be defined as restricted, which is a hint to the compiler to disallow two restricted pointers from being aliases to the same object which allows for certain optimizations when dealing with the said pointers. 

_Bool Macro: There is a _Bool type which is a actually two valued integer type. True is defined as 
#define true (_Bool)1 
while false is defined as 
#define false (_Bool)0 
Variable Declarations can appear anywhere in the code block: No longer do variables have to be defined at the top of the code block. 

Variable length arrays: These are arrays whose size is determined at runtime. 

Variable declarations in for loops: Variables can now be declared and initialized in for loops just like in C++ and Java. 

Named initialization of structs: The members of a struct can now be initialized by name such as is done in the code block below 
struct {float x, y, z;} s = { .y = 1.0, .x = 3.5, .z = 12.8}; 
New long long type: There is a new type called long long which is at least 64 bits and can be both signed or unsigned. The new suffixes "LL" or "ll" (and "ULL" or "ull") are used for constants of the new long long type.

Functions must declare a return value: Function return types no longer defaults to int if the function declares no return type. 

Last member of a struct may be an incomplete array type. : This is to support the "struct hack" which works on most existing C compilers already. A code example of the struct hack is shown on Thomas's site. 

Addition of _Complex and _Imaginary number types: A boon for programmers doing any sort of advanced math in their programs. 

Multiple uses of a type qualifier are ignored after the first occurence: If a type qualifier appears several times (either directly or indirectly through typedefs) in a type specification, it's treated as if it appeared only once. E.g. 
const const int x; 
is the same as 
const int x; 
C++ Incompatibilities

The aforementioned features are rather impressive but one soon realizes that this means that C is no longer a subset of C++. There is a list of the major incompatibilities between the current ISO standards for C and C++ on David Tribble's webpage. At this point it is still too early to see if either C or C++ will be harmed by this development but it is clear that there will be some growing pains once C99 adoption becomes widespread. 

Bjarne Stroustrup mentioned in a recent interview with LinuxWorld that he would have liked for both languages to be compatible and would favor a technical committee whose express purpose would be integrating both languages, but doubts the possibility of this coming to pass. Stroustrup also contrasted how C's technical commitee decided to implement most of the added functionality via changes to the actual C language against the C++ approach which was by adding additional libraries. 

Compiler support

After describing all the exciting new features of C99, one would expect there to be more awareness of the standard by now but there isn't. The primary reason for the lack of awareness of C99 is the fact that compiler support at the current time is practically non-existent. Here is the status of the major compiler vendors for the development platforms that I'm interested in: 
Microsoft: A search on Microsoft's site for C99 draws a total blank. It looks like Microsoft does not plan to upgrade the C compiler that ships with Visual C++ to cover the C99 standard. 

Borland: A search on Borland's site for C99 also draws a blank. Again it looks like exclusive C++ development has won over keeping their C compiler up to date. 

Comeau Computing: The most recent version of their compiler (version 4.2.45.1) which is available for online testing claims to support a large number of features from C99. The compiler has not yet been released but can be tested online by submitting code snippets in an HTML form. 

SAS Institute: SAS/C version 7.0 supports the "long long" type, inline functions and a few of the preprocessor directives. 

Edison Design Group: The EDG C++ front end supposedly supports both C89 and C99 as well as Microsoft C++ and ANSI/ISO C++. 

GNU: GCC has a status page of C99 compliance which shows that they are quite close to becoming fully compliant with the C99 standard. 


Where To Get It

If you are interested in being the first kid on your block who knows the finer points of restricted pointers and variable argument macros, you can purchase the C99 standard online from ANSI. Finally no discussion of C99 is complete without a reference to Dennis Ritchie's opinion of the C99 standard. 

[0] I didn't buy a copy of the standard, so I cannot guarantee that everything on that site made it into the standard although there is a good chance that everything did.

C99标志着C与C++分道扬镳,C不再是C++的子集了。M$不仅目前不太支持,似乎未来也不打算支持(除非未来C++0x会采纳一些C99)。而GCC已经完美支持C99了。

...
Read More
 
/* google analytics */