Linux下C和C++开发基础
Linux下C和C++开发基础
基本编程概念
n 编程语言:C 、C++
n 编译(compile):源文件(.c)->目标文件(.o)
n 连接(link):目标文件(.o)->可执行文件
n 库(library):静态连接库(.a)、动态连接库(.so)
Linux下开发工具
n编辑器:vi、emacs、窗口编辑器
n编译器:GCC
n调试器:GDB
n可执行文件工具:Binutils
n连接器:ld
n汇编程序:as
n库管理工具:ar
n可执行文件符号管理:nm
n显示可执行文件信息:objdump
简单程序示例(C语言):
n hello.c
/***************************
C代码
#i nclude <stdio.h>
int main(int argc,char **argv)
{
printf("HelloWorld!\n");
return 0;
}
/***************************
n编译方法:gcc –o hello hello.c
n运行方法:./hello
简单程序示例(C++语言):
#i nclude <stdio.h>
int main(int argc,char **argv)
{
printf("HelloWorld!\n");
return 0;
}
/***************************
n编译方法:gcc –o hello hello.c
n运行方法:./hello
简单程序示例(C++语言):
n hello.cpp
/*******************************
C代码
#i nclude <iostream>
using namespace std;
int main(int argc,char **argv)
{
cout << "Hello World!“ << endl;
return 0;
}
#i nclude <iostream>
using namespace std;
int main(int argc,char **argv)
{
cout << "Hello World!“ << endl;
return 0;
}
/*******************************
n 编译方法:g++ –o hello hello.cpp
n 运行方法:./hello
GCC编译器
n GNU平台下主流编译器
n目前最新稳定版4.0
n官方网站:http://gcc.gnu.org
n支持编译语言:C、C++、Objective-C、
Objective-C++、Java、Fortran、Ada
n跨平台支持:支持几乎所有主流操作系统,如
Linux、UNIX、Windows等。支持多种硬件平
台,如X86、ARM、PPC、MIPS等
n交叉编译
相关文档:
例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......
最近本来是要去那嵌入式课的,但是那课竟然说人数太少,开不了,靠。所以这两天只能自己研究点东西了。记得自己以前就想动手写一个关于dom的解析引擎,只怪自己太懒,一直没动笔。最近在家也没什么事做,就自己动手写一个,花了一天时间写的差不多了,正好锻炼自己的c++水平吧。
&nb ......
C字符串处理函数的实现(Linux)
#include <stddef.h>
char * ___strtok = NULL;
char * strcpy(char * dest,const char *src)
{
char *tmp = dest;
while ((*dest++ = *src++) != '\0')
/* nothing */;
return tmp;
}
char * strncpy(char * des ......