编写C/C++头文件
头文件一般由三部分内容组成:(1)头文件开头处的版权和版本声明;(2)预处理块;(3)函数和类结构声明等。
头文件扩展名为*.h。
为避免出现重复定义的问题 ,头文件一般写法如下:
/*----------------------------------------------------
MATH.H
-------------------------------------------------------*/
#ifndef _MATH_H_ //防止MATH.h被重复引用
#define _MATH_H_
//代码部分
#endif
例标准math.h写法如下:
/*--------------------------------------------------------------------------
MATH.H
Prototypes for mathematic functions.
Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
All rights reserved.
--------------------------------------------------------------------------*/
#ifndef __MATH_H__ //防止MATH.h被重复引用
#define __MATH_H__
#pragma SAVE
#pragma REGPARMS
extern char cabs (char val); //函数申明部分
extern int abs (int val);
extern long labs (long val);
extern float fabs (float val);
extern float sqrt (float val);
extern float exp (float val);
extern float log (float val);
extern float log10 (float val);
extern float sin (float val);
extern float cos (float val);
extern float tan (float val);
extern float asin (float val);
extern float acos (float val);
extern float atan (float val);
extern float sinh (float val);
extern float cosh (float val);
extern float tanh (float val);
extern float atan2 (float y, float x);
extern float ceil (float val);
exter
相关文档:
#include "mex.h"
#define DWORD long
#define NUMBER_OF_STRUCTS (sizeof(friends)/sizeof(struct phonebook))
#define NUMBER_OF_FIELDS (sizeof(field_names)/sizeof(*field_names))
void mexFunction(int nlhs,
mxArray * plhs[] , int nrhs,const mxArray * pahs[])
{
typedef struc ......
char *strcpy(char *strDes, const char *strSrc)
{
assert((strDes != NULL) && (strSrc != NULL));
char *address = strDes;
while ((*strDes + ......
参考《linux内核完全注释》和网上相关文章
/*
* 控制台显示操作
*/
/*
* linux/kernel/console.c
*
* (C) 1991 Linus Torvalds
*/
/*
* console.c
*
* This module implements the console io functions
* 'void con_init(v ......