Keith Thompson said:
We can't point out what you did wrong without knowing exactly what you
did. Sometimes we can figure out the problem from a brief
description; in this case, we can't.
I suspect the problem is in some detail that you're not telling us,
perhaps because you've assumed it's not significant. That's
understandable; if you were knowledgeable enough to know exactly
what's significant and what isn't, you probably wouldn't have to come
to us for help. Since you are coming to us for help, you really
should give us the information we're asking for. We need a verbatim
cut-and-paste *brief* example of the C code that's causing the
problem. Without that, we can't help you.
Sounds good. I'll post that at the bottom of this reply.
[...]
That's fine. I was only replying to your email as you emailed me.
[...]
This is Usenet, not email. The difference is significant; though your
remarks here might be aimed at one person, there are many more
listening in.
True. I actually was replying to an email. Mr. Tisdale had replied to my
post
over email and cc'd the newsgroup. I did a reply all and replied to both.
I
should've realized it probably shouldn't have gone to the newsgroup as well
(being more
of a personal reply). My apologies for breaking any Usenet etiquette.
You can continue describing what you're doing, and we can continue
telling you we don't know what the problem is. Or you can show us
what you're doing, and we can probably help. The choice is yours (but
one of the choices would be a collosal waste of time and, well, rude.)
Ok, here's my header file r_climat.h
struct data_record
{
...
};
struct data_list
{
struct data_record * head;
struct data_record * tail;
};
struct parameter_list
{
...
}parameters;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
/* Global variables */
extern int FORMAT_TYPE;
extern char PARAM_FILE[256];
extern char * IN_FILE;
extern char OUT_FILE[13];
extern void init(struct data_list * l);
extern struct data_record * new_node(long int sid, long int date, int year,
int month, int element, long int val[96], char f[32]);
extern void add_to_tail(struct data_list * l, long int sid, long int date,
int year, int month, int element, long int val[96], char f[32]);
extern int remove_record(struct data_list * ls, struct data_record * rec);
extern void get_filename(char * filename, char * outname);
extern int validate_format(char * f);
extern void print_list(struct data_list * dl);
extern int format_HLY(char * f);
extern int f_eat_spaces(FILE * f);
extern int get_parameters();
extern void empty_list(struct data_list * d);
extern int get_number_of_days(struct data_record * d);
extern int to_CSV_DLY(char * filename, struct data_list * list);
extern int format_DLY(char * f, struct data_list * dl);
extern int format_MLY(char * f);
extern int format_FIF(char * f);
I tried with and without the #ifndef/#define/#endif and as well with and
without the extern on the functions.
I was able to figure out what was wrong with the undefined references to my
global variables. I declared them here, but not in my .c file. So I don't
have that error anymore.
As for my "multiple declaration" problem, here's the snippet of my .c files:
#include "r_climat.h"
#define HLY 0
#define DLY 1
#define MLY 2
#define FIF 3
int FORMAT_TYPE;
char PARAM_FILE[256];
char * IN_FILE;
char OUT_FILE[13];
int main(int argv, char * argc[])
{
main program here
}
#include "r_climat.h"
#define HLY 0
#define DLY 1
#define MLY 2
#define FIF 3
/* initialize head and tail of data_list to NULL */
void init(struct data_list * l)
{
l->head=NULL;
l->tail=NULL;
}
and the rest of my functions that would take another 800 lines or so.
I only define them in my r_climat.c (I know I don't define any in main.c)
and I only prototype them
in r_climat.h. They all compile just fine with no errors or warnings. It
is during linking that I get this
"multiple definitions" error.
Let me know if there is anything else specific you would like.
Thanks again for all your help. I really do appreciate all of it.
Best regards,
John