易截截图软件、单文件、免安装、纯绿色、仅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++程序控制环境变量

In C++, how do i go about using setenv to set the display?  I need to set it like this:
export DISPLAY=0.0
1、setenv("DISPLAY",":0.1",1);
If you're calling the xrandr functions from your C++ program, then I would expect setenv() should work for you. The 3rd argument of 1 tells setenv() to ov ......

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


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