gpt4 book ai didi

c++ - 在头文件中包含函数

转载 作者:行者123 更新时间:2023-11-30 01:57:44 26 4
gpt4 key购买 nike

<分区>

我有头文件:

字典.h:

#ifndef dictionary_h__
#define dictionary_h__

extern char *BoyerMoore_positive(char *string, int strLength);
extern char *BoyerMoore_negative(char *string, int strLength);
extern char *BoyerMoore_skip(char *string, int strLength);

#endif

函数定义:dictionary.cpp

#include<stdio.h>
#include<string.h>
char *BoyerMoore_positive(char *string, int strLength)
{
} ---- //for each function

和主文件main.cpp:

#include "dictionary.h"
#pragma GCC diagnostic ignored "-Wwrite-strings"
using namespace std;
void *SocketHandler(void *);

int main(int argv, char **argc)
{

----

skp = BoyerMoore_skip(ch[i], strlen(ch[i]) );
if(skp != NULL)
{
i++;
printf("in\n");
continue;
}
printf("\n hi2 \n");
str = BoyerMoore_positive(ch[i], strlen(ch[i]) );
str2= BoyerMoore_negative(ch[i], strlen(ch[i]) );
----
}

当我执行 main.cpp 时

它给出:

/tmp/ccNxb1ix.o: In function `SocketHandler(void*)':
LinServer.cpp:(.text+0x524): undefined reference to `BoyerMoore_skip(char*, int)'
LinServer.cpp:(.text+0x587): undefined reference to `BoyerMoore_positive(char*, int)'
LinServer.cpp:(.text+0x5bd): undefined reference to `BoyerMoore_negative(char*, int)'
collect2: error: ld returned 1 exit status

不知道为什么找不到函数!帮助表示赞赏!

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com