Tuesday, February 15, 2011

ちょっと面白いBlog発見

漢のコンピュータ道」というもので、個人作のわりに、内容がしっかりしていて、読み応えもあります。作者がギークと自称しているが、普通に正論としか言いようのない投稿ばかりです。読んでいて楽しいものです。

Low Atitude Panorama Posts

Found posts, on panoramio by imageabove, of low atitude panorama pictures. One of the most favorite posts is a perspective above Google headquater as linked below.

Wednesday, February 2, 2011

GCC precompiler - Token concatenation ##

According to wikipedia, "##" is used to combine two macro arguments together, by GCC precompiler.
Token concatenation, also called token pasting, is one of the most subtle — and easy to abuse — features of the C macro preprocessor. Two arguments can be 'glued' together using ## preprocessor operator; this allows two tokens to be concatenated in the preprocessed code. This can be used to construct elaborate macros which act like a crude version of C++ templates.
For instance:
#define MYCASE(item,id) \
case id: \
  item##_##id = id;\
break
 
switch(x) {
    MYCASE(widget,23);
}
The line MYCASE(widget,23); gets expanded here into
case 23:
  widget_23 = 23;
break;
(The semicolon following the invocation of MYCASE becomes the semicolon that completes the break statement.)