Dependent Origination

Archive for February 2013

说好了写月记 那就一定要写 看看今年能记得几次~ :)

1. 工作很忙 过了年 先是被领导紧急派去研究我两年前用phonegap + html5 写的iPhone app在现在的dev environment里面表现如何 我们的旧问题有没有在新的库里得到解决 结果花了两个星期 每天头大如斗 让一个旧APP在各种新LIBRARY里面重生 最后结果不尽满意 所以结论是大概还要继续在NATIVE的路上走下去

2. 后面两周虽然没有被各种不知道是什么虫子的日子折磨 但是因为二月份要RELEASE 赶一个INDUSTRY CONFERENCE 所以开始赶工 每天写得眼睛都直了 连睡和以前一样的时间都觉得没睡够 需要增加每天在床上躺着的时间

3. 新的一年 我去一个认识了几年的医生那里针灸 居然有奇效 第一次针灸之后 精力马上就变好了 早上六点多就醒了 起来的时候觉得有精神了 然后第一个星期居然小小的上火了 后来医生说我第一次针灸反应非常迅速 新陈代谢马上提高 所以要比平时喝更多的水才行 我猛喝了两天水 果然一切正常了 两三次之后 我居然把家里的温度从七十一度调到了六十八度 也不觉得冷了 这是十几年从未发生过的事情 人生第一次见识了中医的厉害 果然有好东西

4. 从去年紧锣密鼓地做了很多义工 20号那天最后一次活动结束 我躺在床上觉得很幸福 快乐的感觉充满身体和识田 切实地感觉到自己的障碍在减少 希望所求能够圆满

5. 从去年圆根灯会上听到别人每天诵经的分享 第二天就从床上跳了起来 开始每天一卷地诵经 整个一月份应该只漏掉了一天 去针灸地那天很早离开家 又很晚回家 所以没有时间诵 但是后来我都在后一天补了一卷给前一天 所以坚持了这两个月 很满意:)

git pull –rebase

without rebase, it pulls the changes in depot and does a merge with the current branch.

with rebase, it pulls the changes in depot and applies your changes on top of those.

the difference is in the history: one is a merge, the other is a straight line going forward.

you can also set the following in your ~/.gitconfig file

autosetuprebase = always

This article explains well.

This is a follow up to the previous post about multiple definitions during linking. In it, we used inline so the functions will disappear from symbol table and no linker complain. When it comes to string literals, it is apparent that we cannot just define them in the header file — there is no way of taking them out from the symbol table and it is inevitable for the multiple definitions error. However, we can move the definition to the implementation file and leave an extern declaration in the header file. This way, the linker won’t complain — at the place of reference, the header file is inlcuded, which has the extern declaration so the compiler is happy. The actual definition (and storage allocation, entering into symbol table etc) happens in the implementation file, which if we compile it into a separate library, will only be introduced once by the smart linker.

Problem solved. Old school way.

say I have this template function in a header file.

class A {

template<typename T>

bool my_function(T& t);


And its implementation is in a separate cc file. There has been undefined reference errors during linking and I was puzzled. Luckily, amid the puzzling, I noticed that my class A has other functions, which are not template, and which are compiling and linking fine. So this is no visibility issue but gotta be related to it being a template function.

This realization then makes subsequent googling easy: here is exactly same problem on StackOverflow. The solution is you have to put implementation into the same header file, because the compiler has to see the implementation at the time of compiling — it has to be able to instantiate the function during compiling stage. In other words, it has to produce a compiled version of the instantiation of the templated function. It cannot wait until link time.

Remember I have met the same problem years ago, while I was new at the previous job and spent hours figuring out this. Hopefully now I remember this and won’t be puzzled any more in the future 🙂

February 2013
« Jan   Mar »


  • couldn't get over the jetlag, sleeping during the day from seven to four, for days. 1 month ago
  • is emptying trash and happily discovering the available disk space now ranks at 100G+. 2 months ago
  • is looking at other people's intentions, not their capabilities, and feeling much happier every day :) 1 year ago
  • is planning on how to spend the next two weeks until the new year, at home. 1 year ago
  • is going to have human company for Thanksgiving; a rare event for the past like twenty years. 1 year ago

Flickr Photos











More Photos