Note that there are some explanatory texts on larger screens.

plurals
  1. POOdd duplicate symbol error in C
    text
    copied!<p>Ok so i have a project, and i have some helper functions which need to be shared in various other files. call it Helper.c /.h , with the corresponding compilation flag to avoid multiple inclusion (#ifndef SymbolName #define Symbolname blah blahblah #endif). Every file has its header file in the following way:</p> <pre><code>#include .... #include .... #ifndef __FILENAME_H__ #define __FILENAME_H__ //in each file(FILENAME is replaced for the current file's name) declarations of functions, types, etc. #endif </code></pre> <p>I have a compare function, called dummyCompare (templates, so when creating a variable of this ADT, you need to supply your own function pointer for it to work, so for some cases i don't need a specific function, just a generic one, so that is what dummyCompare is. The error i get when compiling is:</p> <pre><code>gcc ./Helper.c ./LinkedList.c ./ABB.c ./AVL.c -Wall -lm -D DEBUG -g duplicate symbol _dummyCompare in: /var/folders/f2/nghjrbz915vbhjw_1gbb65sm0000gn/T//cc75R4sQ.o /var/folders/f2/nghjrbz915vbhjw_1gbb65sm0000gn/T//cc8jQwyE.o ld: 1 duplicate symbol for architecture x86_64 collect2: ld returned 1 exit status </code></pre> <p>List is used for a non-recursive solution for tree operations in ABB(ABB = BST in spanish)/AVL. Now using Sublime Text 2, i get the following search results for "dummyCompare"</p> <pre><code>Searching 8 files for "dummycompare" /dir/ABB.c: 81 if (abb != NULL) { 82 if (ABB_getRoot(*abb) != NULL){ 83: list = LL_newList(dummyCompare); 84 LL_insert(list, 1, ABB_getRoot(*abb)); 85 /dir/AVL.c: 67 if (avl != NULL) { 68 if (AVL_getRoot(*avl) != NULL){ 69: list = LL_newList(dummyCompare); 70 LL_insert(list, 1, AVL_getRoot(*avl)); 71 /dir/Helper.c: 2 3 /**************************************************************************** 4: * dummyCompare * 5 ***************************************************************************** 6 * Retorna si 2 dirrecciones son iguales, necesario para el funcionamiento * 7 * de la lista * 8 ****************************************************************************/ 9: int dummyCompare(void * a, void * b) 10 { 11 if (a == b) /dir/Helper.h: 4 5 int getMax(int a, int b); 6: int dummyCompare(void * a, void * b); 7 8 #endif 5 matches across 4 files </code></pre> <p>Thing is i can't seem to understand what is wrong, and why am I getting this error. Checked a lot of other question, and only answer i found was ("use #ifndef ... "), which I'm using</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload