当前位置:首页 » 专业资讯
开发技术指南» 文章正文
    引言: c与c++程序连接问题 它们之间的连接问题主要是因为c c++编绎器对函数名译码的方式不同所引起的……考虑下面两个函数 /* c*/ int strlen(char* string) { ... } //c++ int strlen(char* string)...
 

 

 ·fedora bridge script for qos shaping    »显示摘要«
    摘要:续...#! /bin/sh# ## /sbin/init.d/bridge# chkconfig: 345 25 75# description: bridge configuration script for hli by ron senykoff# . /etc/rc.configreturn=$rc_donebridgename="mybridge1"gateway="x.x.x.x"bridge_ip=&q......
 ·linux系统ioctl使用示例    »显示摘要«
    摘要:i love linux and open source,but i love my girl more.      these were writed and collected by kf701,you can use and modify them but no warranty.  contact with me : kf_701@21cn.com程序1:检测接口的 inet_addr,netmas......


c与c++程序连接问题
c与c++程序连接问题 它们之间的连接问题主要是因为c c++编绎器对函数名译码的方式不同所引起的……

考虑下面两个函数 /* c*/ int strlen(char* string) { ... } //c++ int strlen(char* string) { ... } 两个函数完全一样。在c在函数是通过函数名来识别的,而在c++中,由于存在函数的重载问题,函数的识别方式通函数名,函数的返回类型,函数参数列表三者组合来完成的。因此上面两个相同的函数,经过c,c++编绎后会产生完全不同的名字。所以,如果把一个用c编绎器编绎的目标代码与一个用c++编绎器编绎的目标代码进行连接,就会出现连接失败的错误。 解决的方法是使用extern c,避免c++编绎器按照c++的方式去编绎c函数 在头文件中定义: extern "c" int strlen(char* string) 或 extern "c" { int strlen(char* string) } 当c编绎器遇到extern "c"的时候就用传统的c函数编译方法对该函数进行编译。由于c编绎器不认识extern "c"这个编绎指令,而程序员又希望c,c++程序能共用这个头文件,因此通常在头文件中使用_cplusplus宏进行区分: #if define _cplusplus extern "c"{ #endif int strlen(char* string) #ifdefine _cplusplus } #endif 虽然很基础,但是解释透彻!

 ·玩转idt    »显示摘要«
    摘要:好文章,当然放上. 0 - 前言 1 - 绪论 2 - 介绍 2.1 - 什么是中断(interrupt)? 2.2 - 中断和异常(exception) 2.3 - 中断向量 2.4 - 什么是idt? 3 - 异常 3.1 - 异常列表 3.2 - 当异常出现时会发生什么 ? 3.3 - 中断钩子(hooking) by mammon 3.4 - 一般中断钩子 3.5 - profit钩子 : 我们第一个后门 3.6 - fun钩子 4 - 硬件中断 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE