易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 :

C++中extern “C”含义深层探索

(转)C++中extern “C”含义深层探索
 
 
1.引言
  C++语言的创建初衷是“a better C”,但是这并不意味着C++中类似C语言的全局变量和函数所采用的编译和连接方式与C语言完全相同。作为一种欲与C兼容的语言,C++保留了一部分过程式语言的特点(被世人称为“不彻底地面向对象”),因而它可以定义不属于任何类的全局变量和函数。但是,C++毕竟是一种面向对象的程序设计语言,为了支持函数的重载,C++对全局函数的处理方式与C有明显的不同。
  2.从标准头文件说起
  某企业曾经给出如下的一道面试题:
  面试题
  为什么标准头文件都有类似以下的结构?
#ifndef __INCvxWorksh
#define __INCvxWorksh
#ifdef __cplusplus
extern "C" {
#endif
/*...*/
#ifdef __cplusplus
}
#endif
#endif /* __INCvxWorksh */
  分析
  显然,头文件中的编译宏“#ifndef __INCvxWorksh、#define __INCvxWorksh、#endif” 的作用是防止该头文件被重复引用。
  那么
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
  的作用又是什么呢?我们将在下文一一道来。
& ......

C++中extern “C”含义深层探索

(转)C++中extern “C”含义深层探索
 
 
1.引言
  C++语言的创建初衷是“a better C”,但是这并不意味着C++中类似C语言的全局变量和函数所采用的编译和连接方式与C语言完全相同。作为一种欲与C兼容的语言,C++保留了一部分过程式语言的特点(被世人称为“不彻底地面向对象”),因而它可以定义不属于任何类的全局变量和函数。但是,C++毕竟是一种面向对象的程序设计语言,为了支持函数的重载,C++对全局函数的处理方式与C有明显的不同。
  2.从标准头文件说起
  某企业曾经给出如下的一道面试题:
  面试题
  为什么标准头文件都有类似以下的结构?
#ifndef __INCvxWorksh
#define __INCvxWorksh
#ifdef __cplusplus
extern "C" {
#endif
/*...*/
#ifdef __cplusplus
}
#endif
#endif /* __INCvxWorksh */
  分析
  显然,头文件中的编译宏“#ifndef __INCvxWorksh、#define __INCvxWorksh、#endif” 的作用是防止该头文件被重复引用。
  那么
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
  的作用又是什么呢?我们将在下文一一道来。
& ......

GNU C library 笔记1

内容:Introduction 和 Error Reporting
1. glibc 所实现全部或部分规范下的功能有
ISO C: The international standard for the C programming language.
POSIX: The ISO/IEC 9945 (aka IEEE 1003) standards for operating systems.
Berkeley Unix: BSD and SunOS.
SVID: The System V Interface Description.
XPG: The X/Open Portability Guide.
如果只需要 ISO C 的功能,能在编译时使用 -ansi 选项。glibc 实现了全部的 ISO C 功能。POSIX 是 ISO C 的超集,他额外的包括了 file system interface primitives、device-specific terminal control functions、process control functions。Berkeley Unix 实现了前两者多数功能,源于 4.2 BSD、4.3 BSD, and 4.4 BSD Unix 系统(一般称为 Berkeley Unix)及 SunOS (基于 4.2 BSD 不过又实现了 System V 的部分功能),他额外的包括了 symbolic links、the select function、BSD signal functions、sockets。SVID 是 System V Interface Description,也就是描述 AT&T Unix System V operating system 的一份文件,某种意义上是 POSIX 的超集,不过没有已有的 Unix 实现了其全部功能,glibc 也仅仅实现了其部 ......

GNU C library 笔记(2)

内容:Memory
1. 几个基本概念,page、frame、paging、segment。
进程分配内存的两种模式,一个使用 exec 系列函数,一个使用 programmatically(malloc 等函数)。
重要的 segment 有 text segment(存放代码等等,一般在进程的生命周期中不变)、data segment
(存放数据,能用一些函数来调整大小,不过低位端位置不变)、stack segment(随着使用的堆栈
变大而变大,但不变小...)
2. 内存的静态分配和自动分配。前者是对于 static 变量或全局变量,一旦开始就分配,即一直存在到最后。
后者是临时变量,如调用函数。值得注意的是:
In GNU C, the size of the automatic storage can be an expression that
varies. In other C implementations, it must be a constant.
3. 内存的动态分配不为 C 语言本身支持,不像 C++。基本方法是
void * malloc (size_t size)
分配到的内存没有初始化(calloc 会做清零,clear allocate),因此能用 memset 来
进行初始化。分配后应检测返回指针是否为 NULL。malloc 返回的一个块多数情况下对齐
(这样能存储任意类型的数据)过了,地址为 8 的倍数(64 位系统里面是 16 的倍数),
在一些特别情况下(page 的边界)能 ......

Lua 调用C写的动态库遇到的问题及解决

 最近一个项目用lua5.1.4和c++联合开发。在开发的开始阶段遇到了一点问题,问题如下:
用命令行运行:lua test.lua
lua: error loading modules 'dllforlua' from file './dllforlua.dll':
    找不到指定的程序。
因为是第一次使用,这个问题困扰了我好几天。经过多番测试,发现如下规律:
如果用require调用的时候,C动态库的文件名必须要与导出函数保持一致。
例如:动态库名字:testlua.dll,那么导出函数必须如下:
extern "C"
LUALIB_API int luaopen_testlua(lua_State *L) {
 lua_register(L, "average", lua_average);
 return 0;
}
另外一种解决方法,用package.loadlib(绝对路径.dll, "导出函数名")
然后调用这个导出函数
dllentry = package.loadlib("D:\\myprogram\\Lua\\firstC\\Release\\luatest.dll", "luaopen_suibian")
dllentry()
avg, sum = average(10, 20, 30, 40, 50)
print("The average is ", avg)
print("The sum is ", sum)
说明:luatest.dll是动态库的名字,luaopen_suibian是导出函数名,2者可以不一致。
建议用第一种方式。 ......

eat python 003

Documentation for C's fopen():
---
r Open text file for reading. The stream is positioned at the beginning
of the file.
r+ Open for reading and writing. The stream is positioned at the
beginning of the file.
w Truncate file to zero length or create text file for writing. The
stream is positioned at the beginning of the file.
w+ Open for reading and writing. The file is created if it does not
exist, otherwise it is truncated. The stream is positioned at the
beginning of the file.
a Open for writing. The file is created if it does not exist. The stream
is positioned at the end of the file.
a+ Open for reading and writing. The file is created if it does not
exist. The stream is positioned at the end of the file.
======================================================
In Python: http://docs.python.org/library/functions.html#open
Modes 'r+'
, 'w+'
and 'a+'
open the file for updating (note that
'w+'
truncates the file). Append 'b'
to the mode to open the f ......

如何清理asp站点缓存的代码

 <%
Call RemoveAllCache()
Sub RemoveAllCache()
Dim cachelist,i
Call InnerHtml("UpdateInfo","<b>开始执行清理当前站点缓存</b>:")
Cachelist=split(GetallCache(),",")
If UBound(cachelist)>1 Then
For i=0 to UBound(cachelist)-1
DelCahe Cachelist(i)
Call InnerHtml("UpdateInfo","更新 <b>"&cachelist(i)&"</b> 完成")
Next
Call InnerHtml("UpdateInfo","更新了"& UBound(cachelist)-1 &"个缓存对象<br>")
Else
Call InnerHtml("UpdateInfo","<b>当前站点全部缓存清理完成。</b>。")
End If
End Sub
Function GetallCache()
Dim Cacheobj
For Each Cacheobj in Application.Contents
GetallCache = GetallCache & Cacheobj & ","
Next
End Function
Sub DelCahe(MyCaheName)
Application.Lock
Application.Contents.Remove(MyCaheName)
Application.unLock
End Sub
Sub InnerHtml(obj,msg)
Response.Write "<li>"&msg&"</li>"
Response.Flush
End Sub
%> 
......
总记录数:40319; 总页数:6720; 每页6 条; 首页 上一页 [5277] [5278] [5279] [5280] 5281 [5282] [5283] [5284] [5285] [5286]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号