
C/C++
bestboyxie
谢正明
一名喜欢写代码的程序员
bestboyxie@qq.com
展开
-
C++一行一行的读文件
#include #include using namespace std;fstream fin("/opt/nsfocus/etc/config_file.txt"); //打开文件 string readline; while (getline(fin, readline)) //逐行读取,直到结束 { // c原创 2016-08-22 11:50:07 · 11966 阅读 · 0 评论 -
定于与行号有关的变量
#define CONNECT_BC(B,C) B##C#define CONNECT_BB(B,C) CONNECT_BC(B,C)#define D_LINE(A) CONNECT_BB(A,__LINE__)int main(){ int D_LINE(V); }原创 2016-08-25 22:32:05 · 291 阅读 · 0 评论 -
JSCONCPP
#include 字符串转jscon Json::Reader reader; Json::Value root; if (reader.parse(str, root)) // reader将Json字符串解析到root,root将包含Json里所有子元素 { std:原创 2016-08-25 22:40:02 · 1327 阅读 · 0 评论 -
volatile 分析
下面是valatite与普通变量的反汇编代码对比:普通没有加valatite变量再执行自加运算时:1。把值放入rbp寄存器中2。直接将变量寄存器进行自加操作;3。清零eax寄存器加入valatite的变量1。把值放入rbp中,2。取rbp的变量的值放入eax寄存器中3。执行eax寄存器++4。去除eax运算结果放入rbp变量的寄存器中;实际上vo原创 2016-10-31 18:13:35 · 448 阅读 · 0 评论 -
main函数之前执行
一、C语言利用GCC特性#include __attribute((constructor)) void before_main() { printf("%s/n",__FUNCTION__); } __attribute((destructor)) void after_main() { printf("%s/n",__FUNCTION__原创 2016-11-01 14:37:00 · 951 阅读 · 0 评论 -
GNU C - 一个别致的HelloWorld程序 引申到: __attribute__((constructor)|(destructor)(PRIORITY))
转:http://www.cnblogs.com/respawn/archive/2012/07/09/2582078.htmlGNU C - 一个别致的HelloWorld程序 引申到: __attribute__((constructor)|(destructor)(PRIORITY))2012-07-09 04:22 by respawn, 7071 阅读, 1 评论, 收藏,转载 2016-11-02 10:15:34 · 455 阅读 · 0 评论 -
查看GCC的内置宏定义
开发过程中我们常常需要使用宏定义。。为了尽可能多的使用GCC为我们提供的特性,首先我们需要知道gcc提供了那些特性。。。 gcc -dM -E - 没错,就这么一句话就可以搞定了。。。原创 2017-04-07 15:28:10 · 4870 阅读 · 0 评论