我做學校的一個項目,所以我需要編譯它:錯誤在編譯時(可能包括不止一個時間的函數)
gcc hide.c stegano.c -o hide -ansi -pedantic -Wall -Werror
但後來我得到這個錯誤:
/tmp/ccDME1jC.o: In function `calculate_n':
stegano.c:(.text+0x0): multiple definition of `calculate_n'
/tmp/ccQxPZJu.o:hide.c:(.text+0x0): first defined here
/tmp/ccDME1jC.o: In function `tam_msg':
stegano.c:(.text+0x87): multiple definition of `tam_msg'
/tmp/ccQxPZJu.o:hide.c:(.text+0x87): first defined here
/tmp/ccDME1jC.o: In function `insere_msg':
stegano.c:(.text+0xe1): multiple definition of `insere_msg'
/tmp/ccQxPZJu.o:hide.c:(.text+0xe1): first defined here
/tmp/ccDME1jC.o: In function `copia':
stegano.c:(.text+0x201): multiple definition of `copia'
/tmp/ccQxPZJu.o:hide.c:(.text+0x201): first defined here
/tmp/ccDME1jC.o: In function `esconde_msg':
stegano.c:(.text+0x274): multiple definition of `esconde_msg'
/tmp/ccQxPZJu.o:hide.c:(.text+0x274): first defined here
collect2: ld returned 1 exit status
程序代碼是這樣的,我認爲錯誤可能是在包括的我便藏的實際代碼:
程序hide.c是這樣的:
#include <stdio.h>
#include <stdlib.h>
#include "stegano.c"
//code//
然後調用stegano.c,包含在hide.c使用的所有實際功能:
#include <stdio.h>
#include <stdlib.h>
#include "stegano.h"
//code//
而頭文件stegano.h:
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
typedef unsigned char Byte;
void calculate_n(char name[MAX], int* n, int* x);
int tam_msg(char name[MAX]);
void insere_msg(int size, char name[MAX], Byte* v);
void copia(Byte* v1, Byte *v2, int size);
void esconde_msg(Byte* msg, char name1[MAX], char name2[MAX]);
感謝您的幫助!