易截截图软件、单文件、免安装、纯绿色、仅160KB

如何写出专业的C头文件

做到专业,应该是每个职业程序员应该要求自己做到的。
让我们看看lua

怎么写头文件的。
1.License Agreement
License
Agreement
应该加在每个头文件的顶部。
Lua Sample:
/*
** $Id: lua.h,v 1.175b 2003/03/18 12:31:39 roberto Exp $
** Lua - An Extensible Extension Language
** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
** 
http://www.lua.org
    mailto:info@lua.org
** See Copyright Notice at the end of this file
*/
2.guard define
整个头文件应该在guard
define
之间
#ifndef lua_h
#define
 lua_h
#endif
 另外,如果这个头文件可能给
c++
使用,要加上
#ifdef __cplusplus
extern
 
"
C
"
 {
#endif
/*
The lines within extern "C" 
*/
#ifdef __cplusplus
}
#endif
3.
尽量不要在头文件中暴露数据结构
这样可以用户对你的实现的依赖,也减少了用户的编译时间
typedef 
struct
 lua_State lua_State;
LUA_API lua_State 
*
lua_open (
void
);
LUA_API 
void
       lua_close (lua_State 
*
L);
 可以看到虽然用户会一直使用
lua_State,
但是并不知道
lua_State

结构是什么
从一个使用
lua
的例子程序可以看出:
#include 
"
lua.h
"
#include 
"
lauxlib.h
"
#include 
"
lualib.h
"
 
int
 main(
int
 argc, 
char
 
*
argv[])
{
    lua_State 
*

=
 lua_open();
    
const
 
char
 
*
buf 
=
 
"
var = 100
"
;
    
int
 var ;
    luaopen_base(L);
    luaopen_io(L);
    lua_dostring(L, buf);
   &n


相关文档:

c 调用 matlab engine 自定义函数

设置:
1. Tools/Projects and Solutions/VC ++ Directories
    Inlcude files: C:\Program Files\MATLAB\R2009a\extern\include
    Library files: C:\Program Files\MATLAB\R2009a\extern\lib
2. Property
    Configuration Properties/Linker
    ......

简述C和C++程序员学习历程

哈哈!有幸在某网站发现这篇文章,读罢,觉得蛮有道理,发来大家一起共勉之    
总是被同学们问到,如何学习C和C++才不茫然,才不是乱学,想了一下,这里给出一个总的回复。 
' J$ |0 ?! p% w" t5 D6 D: c9 |0 B
  一家之言,欢迎拍砖哈。 
  1、可以考虑先学习C. 
/ U$ X+ X/ P; Y ......

使用C语言扩展Python(五)

上一篇中我们在python端的做法是每次读取一个数据块,然后将这个数据块传递进C扩展模块中去,但对于目标文件的数据写入是在C扩展模块中完成的,但其实可以更面向对象一点,不是吗?原来outfp是一个文件指针,不如改成一个从Python中传递一个文件对象到C模块里去,这个文件对象有自己的write方法,这样在C扩展模块中你就可以 ......

SVD分解C实现

int svd(int m,int n,int withu,int withv,double eps,double tol,
double *a, double *q, double *u, double *v, double *vt)
{

int i,j,k,l,l1,iter,retval;
double c,f,g,h,s,x,y,z;
double *e;

e = (double *)calloc(n,sizeof(double));

retval = 0;
/* Cop ......

【C/C++】static和const的比较和解释


载自http://www.builder.com.cn/
 
       static
是c++中很常用的修饰符,它被用来控制变量的存储方式和可见性,下面我将从 static 修饰符的产生原因、作用谈起,全面分析static
修饰符的实质。
  static 的两大作用:
  一、控制存储方式:
  static被引入以告知编译器,将变 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号