c question!

2. LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

vs 2010
Properties\Configuration Properties\Mai\nifest Tool\Input and Output ---Embed Manifest = No
属性页/配置属性/清单工具/输出和输出/嵌入清单----否

 

2. C不可以返回局部变量(此变量在函数内部调用 ,栈的方式操作的),如果是malloc是可以的

 

3.gcc

set PATH=C:\gcc\bin\;
d:
cd D:\data\source\
del 1.exe
g++ -o 1.exe -ID:\data\source\gccinclude -LD:\data\source\lib 1.c
1.exe
pause

 4.apache cgi 配置

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf

Alias /b "D:/xampp/htdocs/international/"
<Directory "D:/xampp/htdocs/international/">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None    
    Order allow,deny    
    Allow from all
</Directory>

AddHandler cgi-script .cgi

5.Visual Assist X相关

 VA_X.dll位置

C:\Users\用户名\AppData\Local\microsoft\VisualStudio\10.0\Extensions\Whole Tomato Software\Visual Assist X\10.7.1929.0\VA_X.dll

去掉VA的注释下划线 

.安装完Visual Assist X后会在VS2010的菜单栏出现VAssistX这个选项,单击展开,选择Visual AssistX Options;

Advanced/Underlines/去选 Underline spelling errors in comments and strings using

http://www.cnblogs.com/gaojun/archive/2010/03/16/1687304.html

6.static

char *getdate(){  
static char date[10];    ...    
return date;
}
你在函数中定义static变量,在定义的时候须得给他赋值,而且在程序运行中,只有第一次调这个函数时你所赋的值才有效果,
之后每次调此函数,都不会重新给他赋值了(例如staitc a = 10,下次跑这个函数时不会跑这句话了。)。
不过你可以在函数中改变这个值,并且这个值会被保留下来,当你下次调这个函数的时候,得到的值会是你最后给变量所赋的值。
static 变量 是可以改变的。只是在初始化时候只会赋值一次而已。。。
比如你在一个函数里定义 X 变量,那么你每次调这个函数都会去定义这个变量吧,但是如果你把 X 定义为 static 类型,
那么你只会第一次掉它的时候会去定义它,后面调这个函数时,X 变量就已经存在了不会再去定义。但是它的值还是可以改变的。
你可以通过赋值语句改变static变量的值 .

7.MD5Exporter.mzp文件

将MD5Exporter.mzp改名为MD5Exporter.zip然后解压.

8.warning C4005 宏重定义

 

9.===============================================================

C#有泛型,委托,代理这样的高级功能,用C也是可以实现这样的效果:

(1.省略了重复写遍历代码的

(2.遍历算法可以统一控制

一个栈的遍历代理函数

typedef int (*CallBack_Param)(void* p,void* in);
void
LStack_IErgodic(void* _s,void* in,CallBack_Param callBack_Param) { struct LStackNode* s = (struct LStackNode* )_s; void* top,*p; top = s; p=top; while((int)LStack_next(p)){ int data; p=(void*)LStack_next(p); data = LStack_data(p); callBack_Param((void*)data,in);//回调 } }

调用方法:

int f_findName(void* p,void* param)
{
    struct TypeObj* _node = (struct TypeObj*)p;
    int type = _node->type;
    struct    EngineObj* pe = (struct EngineObj*)param;
    if (type == TYPE_MD5_FILE)
    {
        struct MD5_Data* _md5 = (struct MD5_Data* )_node;
        if(strcmp(_md5->name,pe->pfindName) == 0)
        {
            pe->pfindObj = _md5;
        }
    }
    return 0;
}
void* eng_findByName(struct EngineObj *eng,const char* name)
{
    eng->pfindName = (char*)name;
    eng->pfindObj = NULL;
    LStack_IErgodic(eng->renderList,(void*)eng,f_findName);
    return eng->pfindObj;
}

 

为什么C++优于C,其实不难发现上面的两个问题,我用pfindObj,pFindName作为临时变量存储遍历结果的,这两个变量存储在结构体里 我作为参数传递给

LStack_IErgodic的.。因为C的函数是闭包的 我不想用一个全局临时变量摆在外面.如果是C++ 直接作为private使用即可,不用那马麻烦,C把函数和结构体分开了,所以多了写组织工作.
C++有析构,不用手动Free,释放内存等等,管理好类即可,C要做到自动维护管理 需要花点时间自己实现.

 

    函数命名约定说明
    =======================================================================================
    f_IRenderNode    : f_            局部函数,模块内部函数(私有)
                      IRenderNode    I作为接口Interface大写第一个字符,
                                    表示这是一个接口实现,传递CallBack类型的函数回调指针即可
    ---------------------------------------------------------------------------------------
    md5_load        : md5_            模块命md5,(公开)
                      load            模块公共方法

    =======================================================================================
    私有结构体放在 .c文件中
    公用结构体放在 .h文件中

    .h    文件放好函数声明,写好注释和描述信息
    .c    函数实现

10.============================================================================

内存池(降低malloc,free对系统造成的额外开销)

http://blog.chinaunix.net/uid-23629988-id-3264806.html?page=2

@echo off
set ProjectPath=%cd%\
set PATH=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE;
set INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\;
set INCLUDE=%INCLUDE%%ProjectPath%common\;%ProjectPath%include\;%ProjectPath%include\inc\;
set LIB=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\;
set LIB=%LIB%%ProjectPath%lib\;
@rem @echo %ProjectPath%
@rem pause
cd %ProjectPath%dll\
del main.exe
cd %ProjectPath%include\

cl %ProjectPath%include\call.c /Ox /c
cl %ProjectPath%include\h0.c /Ox /c

link /out:test.exe call.obj h0.obj

test.exe

pause

 射线与三角形相交 

http://wenku.baidu.com/link?url=bU7DdIlje395HIuaJLRkCc-mjhaKGD6m9vV4N_141yUV4TwieoQ94rKBZOl83yvIaDwDaV0XNAz04P-WouAaiNC-6HnbFYsK279aX2n8i6y

posted @ 2015-07-23 00:48  泥潭里的金鱼  阅读(285)  评论(0)    收藏  举报