Sunday, December 23, 2007

C Trigraph

Did you notice the following lines are valid C code? It's amazing!

-------------------------------------------------------------------
??=include <stdio.h> /* # */

int main(void)
??< /* { */
char n??(5??); /* [ and ] */

n??(4??) = '0' - (??-0 ??' 1 ??! 2); /* ~, ^ and | */
printf("%c??/n", n??(4??)); /* /, [ and ] */
return 0;
??> /* } */
-------------------------------------------------------------------

This is achieved using the so-called C trigraph. Find more details at http://en.wikipedia.org/wiki/C_trigraph

Wednesday, December 19, 2007

Sunday, December 9, 2007

常用软件快捷键:WinEdit篇

这篇讲讲LaTeX编辑器WinEdit中常用的快捷键。

编辑
Alt+C:在剪贴板原有复制文本后增加新的被选择的文本。
Ctrl+Shift+Alt+Right/Left:对选中文本增加或者删除Comment标记。
Ctrl+Enter:自动完成LaTeX标准命令,cool。
Shift+Enter:对光标所在位置的单词进行英语语法检查
Alt+F12:对选中文本进行LaTeX语法检查(强烈推荐)。

查找
Ctrl+Shift+Backspace/Delete: Moving Ring Backward/Forward。
Ctrl+Shift+F12:括号匹配。

编译
Ctrl+Shift+X:Texify (生成DVI文件)
Ctrl+Shift+D:DVI --> PS
Ctrl+Shift+G:查看PS文件
Ctrl+Shift+B:编译bib文件
Ctrl+Shift+C:编译选中的文本

另 外需要提一下的是WinEdit提供了一个类似MS Word中的Document Map的工具,叫做Gather([Project|Gather])。它提供了当前编辑文档中的所有Bib,Cite,Ref等以及 TOC。特别方便,强烈推荐使用。

Thursday, December 6, 2007

How to comile Qt open source edition in Microsoft Visual Studio

As you may know, although Trolltech's Qt was claimed open-source even for Windows, its open source edition DIDN'T support Microsoft Visual Studio. It's very annoying. I often complained Trolltech was mean (in a strange way). However, it seems Trolltech is becoming more generous. Its latest open source edition of Qt now really supports MS Visual Studio. Gorgeous!

Below I will explain how to compile Qt/Windows open source edition in Microsoft Visual Studio 2005.
  1. Download the Qt source package (.zip NOT .exe) of Windows open source edition at http://trolltech.com/developer/downloads/qt/windows/
  2. Unzip your Qt source to a logical location (NOTE: blank spaces are not allowed), e.g., C:/QT/4.3.3/
  3. Open Visual Studio 2005 Command Prompt (If you are using Windows XP, it is accessible through "Start|All Programs|Microsoft Visual Studio 2005|Vistual Studio Tools|Visual Studio 2005 Command Prompt"). Change your current directory to the unzipped Qt source directory.
  4. Configure your installation using configure.exe. For example, I use "configure.exe -release -no-dsp -vcproj". You can type "configure.exe --help" for detailed help information.
  5. Once configuration is completed, you are now ready to build the library. Simply type "nmake" in the command prompt. Building the Qt library takes a long time (1 hour? maybe). Be patient, :-)
  6. Set up your environment.
    • Add your Qt bin directory to your PATH.
    • Set environment variable QMAKESPEC to win32-msvc2005

That's it. Now you can use Qt in VS 2005. Enjoy. BTW, you can find some related and useful information at QtNode
But note that for QT-4.3.3 (possibly for the future version too), you don't need the patch any more. That's a piece of great news. Thanks, Trolltech.