<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

统计

  • 随笔 - 3
  • 文章 - 0
  • 评论 - 0
  • 引用 - 0

常用链接

留言簿

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

2014年10月16日

visual studio manual debug set

To enable debugging:

1) Goto Project->HelloWorld Properties

2) On the left expand "Configuration Properties"

3) Expand "C/C++"

4) On the left, Select "General"

5) On the right, change "Debug Information Format" to "Program Database For Edit And Continue (/ZI)"

5) On the left, Select "Optimization"

6) On the right, change "Optimization" to "Disabled (/Od)"

7) On the left, expand "Linker"

8) On the left, select "Debugging"

9) On the right, change "Generate Debug Info" to "Yes"

10) Click ok

11) Set your breakpoints

12) Rebuild your application

Also when running your application use Ctrl+F5 to build and run it, this keeps the console window open long enough for you to see your output.

posted @ 2014-10-16 15:50 耳东晨 阅读(272) | 评论 (0)编辑 收藏

2014年8月15日

offsetof宏

最近读libuv源码,看到了ngx_queue_t,里边用到了offsetof,第一次看到,网上查了一下,原来是获取struct成员内存地址相对于struct地址的偏移量,今儿想到了怎么实现的呢。
struct A {
   int i;
   char c;
   float f;
};

A* a = (A*)0;
size_t offset = (size_t)&(a->c);
printf("%lu\n", offset);


#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER ) 

一共4步 
1. ( (TYPE *)0 ) 将零转型为TYPE类型指针; 
2. ((TYPE *)0)->MEMBER 访问结构中的数据成员; 
3. &( ( (TYPE *)0 )->MEMBER )取出数据成员的地址; 
4.(size_t)(&(((TYPE*)0)->MEMBER))结果转换类型.巧妙之处在于将0转换成(TYPE*),结构以内存空间首地址0作为起始地址,则成员地址自然为偏移地址; 

posted @ 2014-08-15 11:57 耳东晨 阅读(171) | 评论 (0)编辑 收藏

2014年8月14日

gyp

首先,我们要先安装gyp

git clone https://chromium.googlesource.com/external/gyp.git
cd gyp
sudo python setup.py install
这个是make file
gyp mylib.gyp --depth=. -f make --generator-output=./build/makefiles
make -C ./build/makefiles/
这个是scons
gyp mylib.gyp --depth=. -f scons --generator-output=./build/sconsfiles
scons -C ./build/sconsfiles/
这个是xcode
gyp mylib.gyp --depth=. -f xcode --generator-output=./build/xcodefiles
xcodebuild -project ./build/xcodefiles/mylib.xcodeproj
这个是ninja
gyp mylib.gyp --depth=. -f ninja
ninja -v -C out/Release/ -f build.ninja
这个是vs
python gyp/gyp mylib.gyp --depth=. -f msvs -G msvs_version=2010
msbuild mylib.sln

gyp脚本编写,接下来再写。








posted @ 2014-08-14 10:21 耳东晨 阅读(962) | 评论 (0)编辑 收藏
仅列出标题