2016-06-02 YongHao Hu
C++
在C语言里, 如何通过输入函数名字来调用函数? 直接上代码. 大致有三种方法: 用函数字典, 缺点是代码耦合在一起, 无法复用. ``` include include include include 继续阅读 »
2016-11-25 LEo
最近项目接近尾声,基本都是在fix bug,今天说说一个bug,是由于strncat函数使用不当导致命令行输出有乱字符。虽说只是一个很简单的小问题,但是不弄明白就是大问题。 1 strncat声明 ```c char *strncat(char *dest, const char *src, size_t n) 继续阅读 »
2016-04-10 craneyuan
什么是Check Check是C语言的一个单元测试框架。它提供一个小巧的单元测试接口。测试案例运行在各自独立的地址空间,所以断言失败和代码错误造成的段错误或者其他的信号可以被捕捉到。另外,测试的结果显示也兼容以下这些格式:Subunit、TAP、XML和通用的日志格式。 Check is a unit testing framework for C. It features a simple interface for defining unit tests, putting little in the way of the developer. Tests are run in a separate address space 继续阅读 »
2016-04-06 AllanChan
身为iOS 的leader最近“不务正业”的去了解了一下有关JS的底层,深有感触的想写一些有关JS数组底层的东西,所以这篇文章就出来了。。 最了几年的程序员,最大的体悟就是你要不断的学习,终生学习才不会让自己退步或者说是脱落。好吧,闲话不说直接进入主题吧。 继续阅读 »
2015-06-23 Klaus Ma
#if __cplusplus >= 201103L #include #else // __cplusplus >= 201103L #include #endif // __cplusplus >= 201103L 继续阅读 »
2015-11-20 Klaus Ma
Named namespaces in Google Code Style Namespaces wrap the entire source file after includes, gflags definitions/declarations and forward declarations of classes from other namespaces. 继续阅读 »
2016-06-17 YongHao Hu
C++
Here is a simple example, what is the output of this program? ``` include using namespace std; int main() { float f = 0.0; int i = 5; f = (float)i; cout< 继续阅读 »
2015-02-24 YongHao Hu
QNAN wiki上是这样说的: A QNaN is a NaN with the most significant fraction bit set. QNaN’s propagate freely through most arithmetic operations. These values pop out of an operation when the result is not mathematically defined. (details)[http://en.wikipedia.org/wiki/NaN] 我尝试过sqrt(-1), 1/0, NAN/NAN都不行 结果: 继续阅读 »
2017-04-09 Mithrilwoodrat
1 之前的项目里做了很多跟 DSL 有关的工作,加上某天在 HackerNews 上看到了how-i-wrote-a-self-hosting-c-compiler-in-40-days 这篇文章,于是又燃起了动手写个玩具编译器的想法。 继续阅读 »
2016-04-01 AllanChan
所有的指针在赋值为NULL、一个引用(地址)或者另一个指针之前都是未被初始化的。 当创建一个指针时,系统只分配了用来存储指针本身的内存空间,并不分配用来存储数据的内存空间。因此在使用指针之前,必须给它赋予一个已分配的内存地址。使用指针的时候一定要注意,不能对未初始化的指针取值!! 继续阅读 »