CUnit (undefined reference) - c

I need to write a program using C and CUnit to test some simple stack functions and using "Makefile" but when I try to compile it, I always get the same errors. The terminal on ubuntu show this when I write the "make" command:
gcc -o Pilhaa_teste.o Pilhaa_teste.c -lcunit
/tmp/ccLqNqAx.o: In function `main':
Pilhaa_teste.c:(.text+0x21): undefined reference to `clean_suite1'
Pilhaa_teste.c:(.text+0x26): undefined reference to `init_suite1'
Pilhaa_teste.c:(.text+0x50): undefined reference to `testaTOP'
The .h that I wrote is:
typedef struct No {
struct No *prox;
int info;
}no;
typedef struct pilha {
no *topo;
}Pilha;
int init_suite1(void);
int clean_suite1(void);
void testaTOP(void);
/*create empty stack*/
Pilha *cria_pilha(void);
/*add one element to the stack*/
void push (Pilha *p, int valor);
/*free first element of stack*/
void pop (Pilha *p);
/*print and find first element*/
int top (Pilha *p);
/*free stack*/
void libera(Pilha *p);
/*print stack*/
void imprime(Pilha *p);
the .c with the main code:
#include <stdlib.h>
#include <stdio.h>
#include "pilha.h"
#include "CUnit/Basic.h"
int main(){
CU_pSuite pSuite = NULL;
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1);
if(NULL == pSuite){
CU_cleanup_registry();
return CU_get_error();
}
if(NULL == CU_add_test(pSuite, "test of top()", testaTOP)){
CU_cleanup_registry();
return CU_get_error();
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
and the clean_suite1, init_suite1 and testaTOP functions:
static Pilha *p = NULL;
int init_suite1(void){
push(p, 6);
if(p!=NULL)
return 0;
else
return 1;
}
int clean_suite1(void){
pop(p);
if (p == NULL)
return 0;
else
return 1;
}
void testaTOP(void){
Pilha *p = NULL;
push (p, 6);
if (p != NULL){
CU_ASSERT(top(p) == 6);
push (p, 7);
if (p != NULL)
CU_ASSERT(top(p) ==7 );
}
no *aux = p->topo->prox;
free(p);
free(aux);
}
the basic functions, push, pop and others are written but there are no problems with them. They were previously used in another program of mine.

gcc -o compiles and links your sources, so either add the .c where functions are implemented or compile separately with gcc -c, which doesn't link source files.

Related

VS code problems suggestion in C

I am writing a HW for school, where I should implement a circular buffer and I ran into 2 things. VS Code says that:
too few arguments in function call [8,21]
expected a ';' [9,5]
But I'am quite sure, I have not made any mistake so far. I also don't know how to compile it, GCC won't take that. Makefile provided by school throws some error, but none regarding this issue.
I've got C/C++ extension form Microsoft [v1.2.2]. Are errors/problems handled by that one?
Here is the code queue.c:
#include "queue.h"
// TODO - your code
queue_t* create_queue(int capacity){
queue_t * q;
q->capacity = capacity;
q->count = 0;
q->arr = malloc(capacity*sizeof(int));
if(q->arr == NULL){
fprintf(stderr, "ERROR: cannot alocate enough memory!\n"); // here is the er#1
}
q->arr_end =(int*)q->arr + capacity * sizeof(int);
return q; // er#2 occurs here
}
And here queue.h
#ifndef __QUEUE_H__
#define __QUEUE_H__
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
/* Queue structure which holds all necessary data */
typedef struct {
// TODO - Include your data structure here
int capacity; // the max # of elemetns, that can be stored
int count; // # of elements in Q
int * arr; // the array itself
int * arr_end; // pointer to the end of arr (ie: *(arr+int*len))
int * read; // position to read from; ie: HEAD
int * write; // position to write form; ie: TAIL
} queue_t;
/* creates a new queue with a given size */
queue_t* create_queue(int capacity);
// ...
#endif /* __QUEUE_H__ */
Output of the GCC for gcc queue.c
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
And this is the main.c as is from school:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "queue.h"
/* allocate new integer with value a and add it to the queue */
void add(int a, queue_t *queue)
{
int *p = (int*)malloc(sizeof(int));
*p = a;
bool ret = push_to_queue(queue, (void*)p);
if (!ret) {
// free memory on failure
free(p);
}
}
/* print the int value on pointer p */
void print_int(void *p)
{
if (p != NULL) {
printf("%d\n", *((int*)p));
} else {
printf("NULL\n");
}
}
/* pop from the queue, print and free the element */
void pop(queue_t *queue)
{
void *p = pop_from_queue(queue);
print_int(p);
free(p);
}
/* get i-th element and print it (do not remove them) */
void get(int idx, queue_t *queue)
{
print_int(get_from_queue(queue, idx));
}
/*
* TEST PROGRAM
* - reads commands from stdin and executes them in the queue
*/
int main(int argc, char *argv[])
{
int n;
/* the tested queue */
queue_t *queue;
// read the size of the queue
scanf("%d", &n);
// create queue
queue = create_queue(n);
while (true) {
char s[2];
// read one command
int ret = scanf("%1s", s);
if (ret != 1) {
break;
}
// add command
if (s[0] == 'a') {
int a;
// read the argument of the command
ret = scanf("%d", &a);
if (ret != 1) {
break;
}
add(a, queue);
// remove command
} else if (s[0] == 'r') {
pop(queue);
// get command
} else if (s[0] == 'g') {
int a;
// read the argument of the command
ret = scanf("%d", &a);
if (ret != 1) {
break;
}
get(a, queue);
}
}
// remove rest of the elements in the queue
while (get_queue_size(queue)) {
void *p = pop_from_queue(queue);
free(p);
}
// free memory
delete_queue(queue);
queue = NULL;
// return 0 on succes
return 0;
}
You forget to reserve space for the queue:
queue_t * q = malloc(sizeof *q);
if (q != NULL)
{
q->capacity = capacity;
...
Also
q->arr_end =(int*)q->arr + capacity * sizeof(int);
here you want (assuming that you want a pointer to the last element):
q->arr_end = q->arr + capacity - 1;
pointer arithmetic is done in terms of elements (not bytes)
Regarding your compile error, it seems that you forget to include the unit containing main, try with
gcc main.c queue.c

Compiling errors in Malloc

I'm following this tutorial to write my own version of malloc and free. The full source code is here which I'm trying to run on my laptop.
I have 3 files:
mymalloc.h
mymalloc.c
memgrind.c // Where my main method is to test my malloc function
I try to compile it by executing the following on the command line:
gcc -c mymalloc.c
gcc -o memgrind.c memgrind
But I get the following errors:
warning: implicit declaration of function MyMalloc [-Wimplicit-function-declaration]
int *p=(int)MyMalloc(100*sizeof(int));
^~~~~~~~
memgrind.c:5:8: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
int *p=(int)MyMalloc(100*sizeof(int));
Am I compiling my files wrong? Or something wrong with the code? (The code I'm executing & compiling is no different to the source code provided in the link)
Thank you.
EDIT:
Now it is compiling correctly but I get this error:
/tmp/ccKyTOaY.o:(.data.rel.local+0x0): multiple definition of `freeList'
/tmp/cc0jpDeq.o:(.data.rel.local+0x0): first defined here
collect2: error: ld returned 1 exit status
But I'm only declaring it once inside of my mymalloc.h?
For reference, here is the code:
mymalloc.c
#include<stdio.h>
#include<stddef.h>
#include "mymalloc.h"
void initialize(){
freeList->size=20000-sizeof(struct block);
freeList->free=1;
freeList->next=NULL;
}
void split(struct block *fitting_slot,size_t size){
struct block *new=(void*)((void*)fitting_slot+size+sizeof(struct block));
new->size=(fitting_slot->size)-size-sizeof(struct block);
new->free=1;
new->next=fitting_slot->next;
fitting_slot->size=size;
fitting_slot->free=0;
fitting_slot->next=new;
}
void *MyMalloc(size_t noOfBytes){
struct block *curr,*prev;
void *result;
if(!(freeList->size)){
initialize();
printf("Memory initialized\n");
}
curr=freeList;
while((((curr->size)<noOfBytes)||((curr->free)==0))&&(curr->next!=NULL)){
prev=curr;
curr=curr->next;
printf("One block checked\n");
}
if((curr->size)==noOfBytes){
curr->free=0;
result=(void*)(++curr);
printf("Exact fitting block allocated\n");
return result;
}
else if((curr->size)>(noOfBytes+sizeof(struct block))){
split(curr,noOfBytes);
result=(void*)(++curr);
printf("Fitting block allocated with a split\n");
return result;
}
else{
result=NULL;
printf("Sorry. No sufficient memory to allocate\n");
return result;
}
}
void merge(){
struct block *curr,*prev;
curr=freeList;
while((curr->next)!=NULL){
if((curr->free) && (curr->next->free)){
curr->size+=(curr->next->size)+sizeof(struct block);
curr->next=curr->next->next;
}
prev=curr;
curr=curr->next;
}
}
void MyFree(void* ptr){
if(((void*)memory<=ptr)&&(ptr<=(void*)(memory+20000))){
struct block* curr=ptr;
--curr;
curr->free=1;
merge();
}
else printf("Please provide a valid pointer allocated by MyMalloc\n");
}
mymalloc.h
#include<stdio.h>
#include<stddef.h>
char memory[20000];
struct block{
size_t size;
int free;
struct block *next;
};
struct block *freeList=(void*)memory;
void initialize();
void split(struct block *fitting_slot,size_t size);
void *MyMalloc(size_t noOfBytes);
void merge();
void MyFree(void* ptr);
memgrind.c
#include<stdio.h>
#include "mymalloc.h"
int main(){
int *p=(int*)MyMalloc(100*sizeof(int));
char *q=(char*)MyMalloc(250*sizeof(char));
int *r=(int*)MyMalloc(1000*sizeof(int));
MyFree(p);
char *w=(char*)MyMalloc(700);
MyFree(r);
int *k=(int*)MyMalloc(500*sizeof(int));
printf("Allocation and deallocation is done successfully!");
}
the warining says that you try to put int into int * so
try this
int *p=(int*)MyMalloc(100*sizeof(int));

Conflicting types for enum bool?

I have a program that gives me the error [Error] conflicting types for 'empty' and [Error] conflicting types for 'full'. I have a hunch that it has something to do with the enum bool use (this is the first time I have tried using it). I've looked at other similar questions, that do not help me, were the issue is forgetting to declare a prototype in the program. I have made sure to write my functions before of main.
This is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct{
char** data; // array of strings represnting the stack
int top; // -1 if empty
int size;
}Stack;
typedef enum { FALSE, TRUE } bool;
Stack* create(){
Stack *s;
s = (Stack*)malloc(sizeof(Stack));
s->top = -1;
s->size = 10;
s->data = (char**)malloc(s->size*sizeof(char*));
return s;
}
void deleteStack(Stack* ps){
while(ps->top = 0){
free(ps->data[ps->top]);
ps->top--;
}
free(ps->data);
}
void push(Stack* ps, char* str, int* size){ //may need to call realloc bfr completing push
if(full(ps)){
char **temp = realloc(ps->data, ps->size*sizeof(char*));
ps->data == temp;
printf("Stack capacity has grown from %d to %d elements\n", ps->size**size, ps->size**(++size));
}
ps->data[++ps->top] = str;
}
char* pop(Stack* s, int* i){ //returns the string that was removed from the stack
if(empty(s))
return NULL;
printf("#of elements after popping: %d\tstring popped: %s\n", --i, s->data[s->top]);
return s->data[s->top--];
}
bool empty(Stack s){ // returns true if stack has no elements else false
if(s.top == -1)
return TRUE;
return FALSE;
}
bool full(Stack s){ //returns true if no more room else false
if(s.top == s.size-1)
return TRUE;
return FALSE;
}
int main(int argc, char *argv[]){
printf("Assignment 2 Problem 1 by Jasmine Ramirez\n");
FILE * input = fopen("data_a2.txt", "r");
if(input == NULL){
printf("File %s not found.\n", "data_a2.txt");
return -1;
}
Stack *s;
s = create();
char str[255];
int i = 0, size = 1;
while(fscanf(input, "%[^\n]", str) == 1){
i++;
if(strcmp(str, "pop") == 0){
i--;
pop(s, &i);
//printf("#of elements after popping: %d\tstring popped: %s", i, temp);
}
else{
push(s, str, &size);
}
}
deleteStack(s);
fclose(input);
return 0;
}
This is the input: (just in case)
to
sure
Be
pop
pop
pop
you
stop
won't
that
feeling
a
have
I
but
on
go
to
much
Not
right
Brilliant
happens
drink
pop
something
and
both
them
Ring
Story
ovaltine
your
pop
pop
Christmas
A
--
pop
pop
pop
pop
Ideas? Or am I just completely off?
In function push() you have:
void push(Stack* ps, char* str, int* size){
if(full(ps)){
…
This implicitly declares full as a function with indeterminate argument list returning an int. You later define it as returning a bool — these are different types, and hence you get the error.
Declare or define full before you use it. Similar comments apply to empty, but there's an additional problem in that code pointed out by Vlad from Moscow in his answer.
If you use GCC, use options such as -Wall -Wextra -Werror -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Wold-style-declaration (or as many of them as your version supports) to ensure that you don't run into this again.
The names empty and full are used before their declarations. For example
char* pop(Stack* s, int* i){ //returns the string that was removed from the stack
if(empty(s))
^^^^^^^^
return NULL;
printf("#of elements after popping: %d\tstring popped: %s\n", --i, s->data[s->top]);
return s->data[s->top--];
}
bool empty(Stack s){ // returns true if stack has no elements else false
if(s.top == -1)
return TRUE;
return FALSE;
}
You must to declare them before their usage.
And moreover for example the function empty has the parameter of the type Stack while is called with an argument of the type Stack *

gcc "multiple definition of " error

So I have these three files
Main.c
#include <assert.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include "support.h"
int main( void ) {
int* num1 = malloc(100);
printf("num1: %p", &num1);
}
Support.c
#include <assert.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "support.h"
void *malloc(size_t size) {
struct block_meta *block;
if (size <= 0) {
return NULL;
}
if (!global_base) { // First call.
block = request_space(NULL, size);
if (!block) {
return NULL;
}
global_base = block;
} else {
struct block_meta *last = global_base;
block = find_free_block(&last, size);
if (!block) { // Failed to find free block.
block = request_space(last, size);
if (!block) {
return NULL;
}
} else { // Found free block
block->free = 0;
block->magic = 0x77777777;
}
}
return(block+1);
}
void free(void *ptr) {
if (!ptr) {
return;
}
struct block_meta* block_ptr = get_block_ptr(ptr);
assert(block_ptr->free == 0);
assert(block_ptr->magic == 0x77777777 || block_ptr->magic == 0x12345678);
block_ptr->free = 1;
block_ptr->magic = 0x55555555;
}
void *realloc(void *ptr, size_t size) {
if (!ptr) {
// NULL ptr. realloc should act like malloc.
return malloc(size);
}
struct block_meta* block_ptr = get_block_ptr(ptr);
if (block_ptr->size >= size) {
// We have enough space. Could free some once we implement split.
return ptr;
}
// Need to really realloc. Malloc new space and free old space.
// Then copy old data to new space.
void *new_ptr;
new_ptr = malloc(size);
if (!new_ptr) {
return NULL; // TODO: set errno on failure.
}
memcpy(new_ptr, ptr, block_ptr->size);
free(ptr);
return new_ptr;
}
void *calloc(size_t nelem, size_t elsize) {
size_t size = nelem * elsize; // TODO: check for overflow.
void *ptr = malloc(size);
memset(ptr, 0, size);
return ptr;
}
Support.h
#include <assert.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
void *malloc(size_t size);
void free(void *ptr);
void *realloc(void *ptr, size_t size);
struct block_meta {
size_t size;
struct block_meta *next;
int free;
int magic; // For debugging only. TODO: remove this in non-debug mode.
};
#define META_SIZE sizeof(struct block_meta)
void *global_base = NULL;
struct block_meta *find_free_block(struct block_meta **last, size_t size) {
struct block_meta *current = global_base;
while (current && !(current->free && current->size >= size)) {
*last = current;
current = current->next;
}
return current;
}
struct block_meta *request_space(struct block_meta* last, size_t size) {
struct block_meta *block;
block = sbrk(0);
void *request = sbrk(size + META_SIZE);
assert((void*)block == request); // Not thread safe.
if (request == (void*) -1) {
return NULL; // sbrk failed.
}
if (last) { // NULL on first request.
last->next = block;
}
block->size = size;
block->next = NULL;
block->free = 0;
block->magic = 0x12345678;
return block;
}
struct block_meta *get_block_ptr(void *ptr) {
return (struct block_meta*)ptr - 1;
}
However when I attempt to compile using
gcc -o asgn2 main.c support.c
I get the error
/tmp/ccscmcbS.o:(.bss+0x0): multiple definition of `global_base'
/tmp/ccyjhjQC.o:(.bss+0x0): first defined here
/tmp/ccscmcbS.o: In function `find_free_block':
support.c:(.text+0x0): multiple definition of `find_free_block'
/tmp/ccyjhjQC.o:main.c:(.text+0x0): first defined here
/tmp/ccscmcbS.o: In function `request_space':
support.c:(.text+0x55): multiple definition of `request_space'
/tmp/ccyjhjQC.o:main.c:(.text+0x55): first defined here
/tmp/ccscmcbS.o: In function `get_block_ptr':
support.c:(.text+0xfe): multiple definition of `get_block_ptr'
/tmp/ccyjhjQC.o:main.c:(.text+0xfe): first defined here
collect2: error: ld returned 1 exit status
I dont believe that I declared those methods more than once, also it is in a much different format than I am usually given. Not quite sure what it means.
The problem is that you have functions and globals defined (as opposed to declared) in your header file. Therefore, those functions are pulled into both main.c and support.c when they are compiled. Then during the linking phase, the linker sees multiple definitions.
Even if you had include guards, it wouldn't help in this case because that only defends against multiple definitions in a single compilation unit, not across multiple units.
Take the definitions of those function out of the header file, replace them with declarations, and put them either in support.c or in a separate .c file.
You can use the -fcommon option for gcc.
Make sure that the header is included only once, so add something like the following to the headers source code:
#ifndef _HAVE_SUPPORT_H
#define _HAVE_SUPPORT_H
// ...
// YOUR HEADER SOURCE CODE
// ...
#endif //_HAVE_SUPPORT_H
As I said this makes sure that the header is included only once, because then it defines _HAVE_SUPPORT_H. If now another source tries to include it, it will not do anything because _HAVE_SUPPRORT_H is already defined.
It also helps if you have only function declarations in the header and your 'real' functions will be in another *.c file.
Edit:
The second parts is the most important for your problem as #kaylum noticed
For me the solution was simple, downgrade to previous GCC version.
Here is comparison gcc installed on two different Ubuntu version.
GCC for ubuntu 20.04: https://packages.ubuntu.com/focal/gcc (gcc 9)
GCC for ubuntu 22.04: https://packages.ubuntu.com/jammy/gcc (gcc 11)
Because on my case, code was legacy code from about 20 years ago, then it makes sense for me to keep using old compiler.

warning: implicit declaration of function TableCreate

I have to build a hash table data structure for this project, which I have done it in other files. For some reason when I compile my program and I get error, which is regarding initialization function (TableCreate();) of hash table. When I remove this part of the code from main function and execute, it works fine but then I get segfault when i try to add something to the hash table.
I believe my hash table code has nothing to do with this errors because my hash table code is based upon examples of Hash table code which was provided to us by our professor
I'm using GCC compiler.
Please help me solve this issue.
Error Message
src/sshell.c: In function âmainâ:
src/sshell.c:34: warning: implicit declaration of function âTableCreateâ
src/sshell.c:34: warning: assignment makes pointer from integer without a cast
sshell.c
#include "parser.h"
#include "shell.h"
#include "hash_table.h"
#include "variables.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int main(void){
char input[1000], sInput[1000]; // String to get user input
int count=1, len; // num=0;
struct Table *t;
t = TableCreate(); //create the table
int while_track;
FILE *ptr_file;
ptr_file =fopen(".simpleshell_history","a");
fclose(ptr_file);
printf("\nWelcome to the sample shell! You may enter commands here, one\n");
printf("per line. When you're finished, press Ctrl+D on a line by\n");
printf("itself. I understand basic commands and arguments separated by\n");
printf("spaces, redirection with < and >, up to two commands joined\n");
printf("by a pipe, tilde expansion, and background commands with &.\n\n");
printf("\npssh$ ");
while (fgets(input, sizeof(input), stdin)) {
strcpy(sInput, input);
len = strlen(input);
if( input[len-1] == '\n' ){
input[len-1] = '\0';
}
while_track = 1; // used to keep track of loop
while (while_track == 1){
count+=1;
if (strcmp(input, "history")==0){
while_track = History(); // print history function call
}else if (strcmp(input, "!!")==0){
while_track = Previous(input); // execute previous function call
}else if (strncmp(input, "!",1)==0){ // !string and !number sort
if(isdigit(input[1])){
while_track = Number(input);
} else {
while_track = String(input);
}
}else { // if the user entry was not any of specfic comnnad then pass the command to parse to execute
other(input,t);
parse(input);
while_track = 0;
}
}
HistoryFile(sInput); // A function call to recode commands entered by the user into a file
printf("\npssh$ ");
}
return 0;
}
hash_table.c
#include "hash_table.h"
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
void feedData(char * var, char * val, struct Table *t){
//const char * key=0;
printf("\n In FeedData Function\n");
Table_add(t, var, val);
printf("\nInside Feed Function -- Veriable: %s Value: %s\n",var, val);
}
unsigned int hash(const char *x) {
printf("\n In Hash\n");
int i;
unsigned int h = 0U;
printf("\n In Hash - Before for loop\n");
for (i=0; x[i]!='\0'; i++)
printf("\n In Hash - In for loop %d \n", i);
h = h * 65599 + (unsigned char)x[i];
printf("\n In Hash - In for loop - after calculation \n");
unsigned int g;
g = h % 1024;
printf("\n In Hash - In for loop - before return: %u \n",g);
return g;
}
struct Table *Table_create(void) {
printf("\n In Table_create\n");
struct Table *t;
t = (struct Table*)calloc(1, sizeof(struct Table));
return t;
}
void Table_add(struct Table *t, const char *key, char * val){
printf("\n In Table_add\n");
struct Node *p = (struct Node*)malloc(sizeof(struct Node));
int h = hash(key);
printf("\n In Table_add - after hash key\n");
//p->key = *key;
strcpy(p->key,key);
printf("\n In Table_add - after first key\n");
strcpy(p->value,val);
printf("\n In Table_add - after Value\n");
p->next = t->array[h];
printf("\n In Table_add - after p->next\n");
t->array[h] = p;
printf("\n In Table_add - after t->array[h] = p\n");
}
/*
int Table_search(struct Table *t, const char *key, int *value){
struct Node *p;
int h = hash(key); //---------------------------------------------------------------------
for (p = t->array[h]; p != NULL; p = p->next)
if (strcmp(p->key, key) == 0) {
*value = p->value;
return 1;
}
return 0;
}
*/
/*
void Table_free(struct Table *t) {
struct Node *p;
struct Node *nextp;
int b;
for (b = 0; b < BUCKET_COUNT; b++)
for (p = t->array[b]; p != NULL; p = nextp) {
nextp = p->next;
free(p);
}
free(t);
}
*/
hash_table.h file code
#ifndef HASH_TABLE_H
#define HASH_TABLE_H
struct Table *Table_create(void);
void Table_add(struct Table *t, const char *key, char * val);
unsigned int hash(const char *x);
void feedData(char * var, char * val, struct Table *t);
enum {BUCKET_COUNT = 1024};
struct Node {
char key[1000];
char variable[1000];
char value[1000];
struct Node *next;
};
struct Table {
struct Node *array[BUCKET_COUNT];
};
#endif
Warning 1: You are calling TableCreate while your function name is Table_create
Warning 2: After looking at new identifier followed by (, compiler assumes it is a function that takes variable number of arguments and returns int.

Resources