首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

单独编译可通过,但是链接时候报错.求原因解决思路

2012-04-04 
单独编译可通过,但是链接时候报错....求原因C/C++ code/*文件名 interface.h*/#include stdio.h#include

单独编译可通过,但是链接时候报错....求原因

C/C++ code
/*文件名 interface.h*/#include <stdio.h>#include <stdlib.h>typedef struct STUDENT{    struct STUDENT *next;    int studentid;    }Student;extern void *my_malloc(size_t size);extern void my_free(void **p);extern void simple_printf(void);extern int simple_insert(int value);#define malloc(size) printf("Don't call malloc().Use MALLOC(num,type) instead.\n");\                        exit(1);#define MALLOC(num,type) (type *)my_malloc((num)*sizeof(type))#define free printf("Don't call free().Use FREE(num,type) instead.\n");\                        exit(1);#define FREE(p) my_free((void **)(&(p)))/*文件名implement.c*/#include "interface.h"#ifdef malloc    #undef malloc#endif#ifdef free    #undef free#endifvoid *my_malloc(size_t size){    void *new_mem;        new_mem = malloc(size);        if(NULL == new_mem)    {        printf("Out of memory!\n");        exit(1);    }        return new_mem;} void my_free(void **p){    free(*p);        *p = NULL;}/*文件名linkedlist.c*/#include "interface.h"static Student * rootp = NULL;int simple_insert(int value){    Student *current = NULL;    Student *previous = NULL;    Student *newStudent = NULL;        current = rootp;        while(current != NULL && current->studentid <value)    {        previous = current;        current = current->next;    }        //newStudent = (Student *)malloc(sizeof(Student));    newStudent = MALLOC(1,Student);    newStudent->studentid = value;    newStudent->next = current;        if(previous != NULL)        previous->next = newStudent;     else        rootp = newStudent;         return 0;   }void simple_printf(void){    Student *current = NULL;    current = rootp;        while(current!= NULL)    {        printf("%d ",current->studentid);        current = current->next;    }        printf("\n");    }/*文件名 main.c*/#include "interface.h"int main(void){    printf("\n");    simple_insert(3012);        simple_printf();}


[解决办法]
vs2008 编译链接都没问题~~
[解决办法]

[解决办法]

[解决办法]

热点排行