受不了了!!

softwarewander 2007-01-26 04:47:32
很弱的问题。但就是解决不掉了。

总是提示
(27): error C2129: static function 'int havekmp(void)' declared but not defined

但是当我双击定位的时候,确实莫名其妙的,main函数所在文件的第一行。



但是我确实已经定义了阿。


...全文
824 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Cnwanglin 2007-01-27
  • 打赏
  • 举报
回复
路过,没看懂,太菜了,继续UP
softwarewander 2007-01-27
  • 打赏
  • 举报
回复
楼上的说的对, 简直太笨了。 以前没写过c/c++的工程代码,虽然知道static的意思,但是在实际运用当中很欠缺的。……

不好意思,但是我又有新问题了
kmps fatal error LNK1104: cannot open file '.\Debug\KMP.obj'
不知道这是什么原因搞得。
softwarewander 2007-01-27
  • 打赏
  • 举报
回复
非常感谢你的耐心解答。

我尝试过的, 有个文件pdb文件无法删除,后来我就把所有的debug中的东西全部删掉,然后再重新build还是不可以。结果后来就产生那个can not open file '.\Debug\KMP.obj' 怎么也搞不定了
无奈,在这样做的,
晨星 2007-01-27
  • 打赏
  • 举报
回复
以后不用重建工程。
先clean了重新编译试试看。
softwarewander 2007-01-27
  • 打赏
  • 举报
回复
问题搞定了,我又重新建了一个工程文件,然后把代码考过去,问题就没有了。

但是始终不知道为什么, 以后遇到这种情况就束手无策了感觉 哎………………
晨星 2007-01-26
  • 打赏
  • 举报
回复
C语言就这么一丁点数据封装的能力,还被楼主给无视了。- -b
晨星 2007-01-26
  • 打赏
  • 举报
回复
要跨文件使用的函数不可以是static的。
static是专门用来指定不准别的文件(编译单元)用,而只准本文件内部用的。
南山浮云 2007-01-26
  • 打赏
  • 举报
回复
static使用错误,去掉static关键字,KMP.h的声明中加上extern关键字。
cunsh 2007-01-26
  • 打赏
  • 举报
回复
KMP.cpp文件
****************************************************************
#include "stdafx.h"
#include "time.h"
#include "MYERROR.h"
#include "KMP.h"
……
然后 定义
static int havekmp() //static. 就是说这个函数的连接属性是内部的.在KMP.cpp之外不能调用它
{
………………
………………
}
softwarewander 2007-01-26
  • 打赏
  • 举报
回复
ms的编译器 简直了……搞了一下午了
郁闷……
iu_81 2007-01-26
  • 打赏
  • 举报
回复
没有问题
softwarewander 2007-01-26
  • 打赏
  • 举报
回复
main 所在文件
********************
#include "stdafx.h"

#include<stdio.h>
#include<string.h>
#include"MYERROR.h"
#include"KMP.h"
#include"NOKMP.h"
#include "time.h"


KMP.h文件
***********************************
#ifndef _FILEKMP_
#define _FILEKMP_

#define MAXLEN 128
static int next[MAXLEN];
static char target[MAXLEN];

static void kmpinit();
/*找出模式字符串中的next值,并将此值存入到next数组中*/
static void get_next(char * want);
static void specify_target(char * p);
static int havekmp();
/*主体的index函数*/
static int findindex(char * source,char *target,int pos);

#endif

KMP.cpp文件
****************************************************************
#include "stdafx.h"
#include "time.h"
#include "MYERROR.h"
#include "KMP.h"
……
然后 定义
static int havekmp()
{
………………
………………
}




有什么不对吗?








todototry 2007-01-26
  • 打赏
  • 举报
回复
把定义放在main()前面

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧