c4,configure the debug environment

  Yesterday I found a tiny C compiler (less than 600 line of C code, containing commits) called "c4" on github and I wanted to know how I can write a compiler in details.

  During the process, I encounter the following problems:

1> Can not compile c4 on Windows platform, because no "unistd.h" on Windows.

solution: replace the include sentence by the following statements:

  许多在Linux下开发的C程序都需要头文件unistd.h,但VC中没有个头文件, 
  所以用VC编译总是报错。把下面的内容保存为unistd.h,可以解决这个问题。

    1.   /** This file is part of the Mingw32 package.
    2.    *  unistd.h maps     (roughly) to io.h
    3.    */
    4.   #ifndef _UNISTD_H
    5.   #define _UNISTD_H
    6.   #include <io.h>
    7.   #include <process.h>
    8.   #endif /* _UNISTD_H */

2> IDEs:

First tried Vitual Studio 2013, it was hard for me to get used the VS after some many years‘ leave. I could not find the proper functions to satisfy my needs.

Eclipse: Downloaded the Eclipse-CDT(for C/C++ development). Dowload the minGW project, containing the gcc and other lib file for windows. Configure eclipse, it is not complicated after I configure the BarLearner project from Cristian. Just make the build system right, and adjust the run configuration. But I fould I could not the value of global values and for most pointers, I could only see the address its point to rather than the  content (for example, I wanted to see an array, but got nothing useful for me.) Searching on the Internet, someone said we can see the global values on "Watch" windows. However, I did not think so after trying. I gave it up temporary.

VC6.0: This is a very old platform I had been working on for years. It took me time to install VC 6.0 on Windows 8.1. Here are some useful solution for the installation:

  “1 改名 MSDEV.EXE改成 MSDEV3.EXE
  2 兼容模式修改成 winxp sp2 或者sp3
  3 启动MSDEV3.EXE,如果报错,关闭,立刻再次启动,一般就可以正常启动了,成功启动一次后,以后就可以正常运行了
  4 取消兼容模式,如果运气好,也可以正常运行了,如果不介意,就一直用兼容模式运行也可以"

After that, I found VC 6.0 can not show line number by default. WTF! I need a plug in to complete this need.

  1. 如果你的VC安装在C盘,请拷贝文件VC6LineNumberAddin.dll到如下目录: C:\Program Files\Microsoft Visual Studio\Common\MSDev98\AddIns

  2. 注册

  双击VC6LineNumberAddin.reg进行注册。

  3. 启用 

  打开vc6,菜单栏:Tools -> customize -> Add-ins and Macro Files 选中VC6LineNumber Developer Studio Add-in

  关闭VC,重启VC即可。

Also, I got a link for setting up vim+GDB environment:

http://easwy.com/blog/archives/advanced-vim-skills-vim-gdb-vimgdb/

时间: 2024-08-24 09:38:00

c4,configure the debug environment的相关文章

ios开发笔记----exc_bad_access(code=1, address=0x789870)野指针错误,假死debug状态

错误原因: exc_bad_access(code=1, address=0x789870)野指针错误,主要的原因是,当某个对象被完全释放,也就是retainCount,引用计数为0后.再去通过该对象去调用其它的方法就会出现野指针错误. 例如: Person *jerry = [[Person alloc]init];  //  retainCount引用计数为1 [jerry eat];  //  调用吃的方法 [jerry release];  //  释放jerry这个对象到 retain

获取项目中文件,存放到Debug中。

说起这个,还真是费了一般功夫. 说个最简单的方法: 第一步:把需要生成到Debug中的文件放到项目中(注意:当前文件夹目录是什么样的,存放到Debug中也是什么样) 第二部:设置文件属性中 复制到输出目录(如果较新则复制:就是在内容更改后就更新,不复制:不会复制,始终复制:如果该文件需要修改,不建议选择此项) 生成操作(无,编译,内容,嵌入的资源) 第三步:已经完成了,是不是很简单. 还有个手动的方法(哈哈,有点麻烦哦!!!): /// <summary> /// 项目中资源文件保存到Debu

给程序加入能打印文件名、行号、日期的日志信息,并设置debug开关

我们在写程序的时候,总是或多或少会加入一些printf之类的语句用于输出调试信息,但是printf语句有个很不方便的地方就是当我们需要发布程序的时候要一条一条的把这些语句删除,而一旦需要再次调试的时候,这些语句又不得不一条条的加上,这给我们带来了很大的不便,浪费了我们很多的时间,也造成了调试的效率低下.所以,很多人会选择使用宏定义的方式来输出调试语句. 比如,定义一个宏开关: #define __DEBUG 当需要调试的时候,使用语句: #ifdef __DEBUG printf(xxx); #

HBase二次开发之搭建HBase调试环境,如何远程debug HBase源代码

版本 HDP:3.0.1.0 HBase:2.0.0 一.前言 之前的文章也提到过,最近工作中需要对HBase进行二次开发(参照HBase的AES加密方法,为HBase增加SMS4数据加密类型).研究了两天,终于将开发流程想清楚并搭建好了debug环境,所以就迫不及待地想写篇文章分享给大家. 二.思路 首先看到这个需求,肯定是需要先实现HBase配置AES加密<HBase配置AES加密>,或者还可以再继续了解实现SMS4加密算法<Java版SMS4加密解密算法>.等到这些都完成之后

NDK开发,如何配置 debug环境

刚开始做NDK 开发的时候,Android Studio 还没提供了 native C/C++ 设置断点 调试,我们都是通过输出 日志来调试,这样费时耗力.Android Studio 应该是在 2.2 版本才提供的设置断点 debug 功能,同时在该版本也提供了 cmake 编译.     我目前在做 NDK 开发的时候,还是习惯用 NDK-Build(也就是设置 Android.mk) 来开发,我先简单说一下怎么用输出日志来调试: 1.首先在 Android.mk 设置MODULE 添加日志

vs2013中$(TargetPath)与Link.OutputFile不同,导致调试debug找不到exe

之前把VS2008项目升级为VS2013项目后,出现了VS2013调试debug找不到exe文件的现象,如:http://blog.sina.com.cn/s/blog_6c617ee301013xtz.html 原因是原工程的属性设置了输出目录在debug下,但是输出文件在bin下 有的方法说把两个目录统一下就好了,但是我就是想把exe单独放在bin下,可以按如下操作: 原本的TargetPath是错的,该目录下没有exe 改成下面这样就好了 另附参考网页: vs2012的debug设置问题

c++ 用freopen简单的重定向,再也不怕debug了~

#define debug //去掉此句话,重定向部分失效 #include<iostream> #include<cstdio> using namespace std; int main() { #ifdef debug freopen("D:\\in.txt","r",stdin); //从in.txt文件输入 freopen("CON","r",stdin); //从控制台读入 freopen(

懒人学习automake, Makefile.am,configure.ac

已经存在Makefile.am,如何生成Makefile? 步骤: [plain] view plain copy [[email protected] hello]# autoscan .///在当前文件夹中搜索 [[email protected] hello]# cp configure.scan configure.ac //复制文件 [[email protected] hello]# vi configure.ac //编辑文件 编辑configure.ac,加入下面一行: AM_I

懒人学习automake, Makefile.am,configure.ac(转)

已经存在Makefile.am,如何生成Makefile? 步骤: 1 [[email protected] hello]# autoscan .///在当前文件夹中搜索 2 3 [[email protected] hello]# cp configure.scan configure.ac //复制文件 4 [[email protected] hello]# vi configure.ac //编辑文件 5 6 编辑configure.ac,加入下面一行: 7 AM_INIT_AUTOMA