Understand the compile time operator: sizeof

During I read the source code of Redis, I found the following code:

dict *d = zmalloc(sizeof(*d));

After searching a different definition of ‘d’, I realized that the d is the same object defined in the same line. In order to understand what happens, Continue reading “Understand the compile time operator: sizeof”

Could not compile libxml2: /bin/rm: cannot remove `libtoolT’: No such file or directory

When I compile libxml2-2.7.8 under Ubuntu 11.04, it always complain that:

/bin/rm: cannot remove `libtoolT’: No such file or directory.

I did a search on google, but none of them works.

From the console output, I found that it failed because removing a file which does not exists.

So I edit the configure file, find the line which contains $RM “$cfgfile”, and replace it with $RM -f “$cfgfile”, then everything works.

(‘rm -f’ means do not stop even if the file doesn’t exists)

基于JavaScript的代码自动生成工具

JavaScript Based Code Generator – codegen

工具主页

http://thelei.sourceforge.net

目的

快速生成程序代码, 比如Struts, Spring, Jdbc/Hibernate所有前后台的代码.

简单介绍

本工具生成代码的思想是读取数据库中表的结构, 使用JavaScript作为脚本语言编写模板, 生成各种代码或者文件, 支持各种格式的文本文件, Java, C#, PHP 等, 只要是文本文件, 都可以生成, 因为生成什么是由你完全自己定义的. 对数据库的访问是通过插件的形式进行的, 所以易于扩充, 目前支持Mysql, 以及支持Ado连接的数据库.

本工具开发于2006年, 经过两年的内部使用, 进行了不断改进, 现在把它公布出来, 希望能有更多的人用它, 提意见, 然后把它做的更好.

什么时候用它

有时候在项目开发过程中有大量的简单重复劳动, 以Struts, Spring, Jdbc/Hibernate为例, 对数据库中的每张表, 都有其相对应的Dao(2), Service(2), Action(Class+Validation2), Jsp(list+edit+add=3), 需要新建10多个文件/目录,  而这个过程是很枯燥的, 但又会花不少时间, Continue reading “基于JavaScript的代码自动生成工具”

Introduce a tool to generate code by writing JavaScript

Java Based Code Generator – jbcgen

home page:

http://sourceforge.net/projects/jbcgen/

Short Description:

This code generator generates files from database and templates written in JavaScript. it supports db plugin, and it’s easy to extend and use. It supports mysql and db which support ado connection(under windows only) for now.

When To Use

It should be used especially when the code logic is similar, but the table is different. It will save much of your time by generating code automatically instead of copy&paste. For example, you want to write 5 files for each table, you only need to write lines of javascript code without coding the files lots of time. Continue reading “Introduce a tool to generate code by writing JavaScript”

type redefinition Error after Import ADO in vc++

It is important to invoke ADO correctly in your program, or you can have compiler errors. The following code demonstrates the correct way to use #import with Msado10.dll the MSADO15.dll:

#import <msado15.dll>
no_namespace
rename("EOF", "adoEOF")

error C2011: ‘EditModeEnum’ : ‘enum’ type redefinition
error C2011: ‘LockTypeEnum’ : ‘enum’ type redefinition
error C2011: ‘FieldAttributeEnum’ : ‘enum’ type redefinition
error C2011: ‘DataTypeEnum’ : ‘enum’ type redefinition
error C2011: ‘ParameterDirectionEnum’ : ‘enum’ type redefinition
error C2011: ‘RecordStatusEnum’ : ‘enum’ type redefinition

Here’s the original solution in MSDN:
http://support.microsoft.com/kb/169496/EN-US/