c语言sscanf函数的用法是什么
363
2022-09-01
杂记 (6) —— vim, gcc, gdb, man
vi vistual block缩进
选中vistual block, shift + > or <
gdb无法调试最新gcc编译的程序
$ gcc -g -o fcopy fcopy.c$ gdb fcopyGNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)Copyright (C) 2010 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later 在gcc官网查看到的信息: General Optimizer Improvements (and Changes) DWARF4 is now the default when generating DWARF debug information. When -g is used on a platform that uses DWARF debugging inform ation, GCC will now default to -gdwarf-4 -fno-debug-types-section. GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 debug information consumers support DWARF4 by default. Before GCC 4.8 the default vers ion used was DWARF2. To make GCC 4.8 generate an older DWARF version use -g together with -gdwarf-2 or -gdwarf-3. The default for Darwin and VxWorks is still -gdwarf-2 大致的意思是 gcc从4.8开始缺省使用了-gdwarf-4选项,较旧的gdb无法识别dwarf4版本的调试信息。 我们可以在用gcc编译程序时,使用选项-gdwarf-2 或者 -gdwarf-3来指定生成低版本的调试信息。 $ gcc -gdwarf-2 -o fcopy fcopy.c$ gdb fcopyGNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)Copyright (C) 2010 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later 在gdb中执行shell命令 (gdb) shell command_string 例如: (gdb) shell cat file3.txt Close your eyes, give me your hand, darling 梦中人熟悉的脸孔 Do you feel my heart beating cannot open shared object file: No such file or directory gcc -o readdir readdir.c/usr/local/GCC-4.9/bin/../libexec/gcc/i686-pc-linux-gnu/4.9.1/cc1: error whileloading shared libraries: libmpc.so.2: cannot open shared object file: Nosuch file or directory 在共享库中找不到库文件libmpc.so.2 搜索他: # find / -name libmpc.so.2/home/edemon/mpc-0.9_temp/src/.libs/libmpc.so.2/usr/local/mpc-0.9/lib/libmpc.so.2 直接拷贝到共享库/usr/lib $ cp /usr/local/mpc-0.9/lib/libmpc.so.2 /usr/lib/$ gcc readdir.c/usr/local/GCC-4.9/bin/../libexec/gcc/i686-pc-linux-gnu/4.9.1/cc1: error whileloading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory 不要紧张这是另一个错误:缺少libmpfr.so.4。哈哈哈,从一个坑跳进了另一个坑。 但是解决的方法已经知道了。 总之就是缺少什么文件,搜索她并拷到/usr/lib即可 怎样用man查找和shell指令同名的函数 通过man man我们得到这样的信息: SYNOPSIS man [-acdDfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-M pathlist] [-P pager] [-B browser] [-H htmlpager] [-S section_list] [section] name ...MANUAL SECTIONS The standard sections of the manual include: 1 User Commands 2 System Calls 3 C Library Functions 4 Devices and Special Files 5 File Formats and Conventions 6 Games et. Al. 7 Miscellanea 8 System Administration tools and Deamons Distributions customize the manual section to their specifics, which often include 比如,现在我遇到link这个函数,用man查看的话得到的不是函数说明,而是命令。 可以这样查看函数。 $ man 2 link 文本编码的转化 例如: [edemon@CentOS ~]$ file unknow unknow: UTF-8 Unicode text 然后,我们借助icnov进行字符编码的转化。 [edemon@CentOS ~]$ icnov -l #可查看支持的所有编码[edemon@CentOS ~]$ iconv -f UTF-8 -t GBK gcc编译得到警告信息:warning: the `gets’ function is dangerous and should not be used. 这主要是因为char *gets(char*s);没有读取字符的限制,有可能出现溢出的危险情况,与这个函数相似的是char *fgets(char *s, int size, FILE *stream);,它有size的限制,所以更加安全。 关于 >&2 下面的解释来自linux中国开源社区 test#!/bin/bashecho " this is ERROR " >&2echo "this is output" 运行脚本 [root@localhost ~]# ./test 2>file1this is output[root@localhost ~]# cat file1this is 使用man在线手册查询命令,重定向后出现了很多的^H 解决方案:使用col -b过滤掉所有的控制字符。 Col reads from standard input and writes to standard output. The options are as follows: -b Do not output any backspaces, printing only the last character written to each 比如: man bash |col -b > read
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~