Hi all,
You were so responsive and helpful to my last query, I've decided to come again.
I'm having a problem during linking, I get the following error:
ld: duplicate symbol _amino_acid_tlc in /Users/davis/Documents/covarion simulation/covarions/build/covarions.build/Debug/covarions.build/Objects-normal/x86_64/structures.o and /Users/davis/Documents/covarion simulation/covarions/build/covarions.build/Debug/covarions.build/Objects-normal/x86_64/main.o
Both main.c and structures.c have structures.h as one of their include files- they are required in both files for successful compilation.
My structures.h file contains
Code:
#ifndef structures_h
#define structures_h
....
#endif
where the .... represents the everything else that is contained in the structures.h file.
My understanding was that this should prevent exactly this sort of error, because it will see that structures_h is defined, and then not include any part of the structures.h file, once it's actually been defined.
amino_acid_tlc is defined only once in all of my files, and if I remove all references to amino_acid_tlc from within the main.c file (but otherwise leave everything else exactly the same), the program compiles and links just fine.
Code:
const char *amino_acid_tlc[22]= {"ala", "cys", "asp", "glu", "phe", "gly", "his", "lle", "lys", "leu", "met", "asn", "pyl", "pro", "gln", "arg", "ser", "thr", "sec","val", "trp", "tyr"};
Note, that if I change that too
Code:
static const char *amino_acid_tlc[22]= {"ala", "cys", "asp", "glu", "phe", "gly", "his", "lle", "lys", "leu", "met", "asn", "pyl", "pro", "gln", "arg", "ser", "thr", "sec","val", "trp", "tyr"};
it compiles just fine, but that doesn't explain why it is still unhappy, even after adding the #ifndef statements at the start of structures.h. I've even tried using #pragma once, and that didn't help either. Using the static keyword is just fine for my purposes, but I'd like to understand what the issue is with #ifindef or #pragma.
Please note I'm using Xcode with gcc 4.2.1.
Any suggestions / comments?
Thanks!
Brad