I'm just trying to get my code to compile, but I keep running into errors:
.\Objects\Lab4.axf: Error: L6200E: Symbol current_process multiply defined (by lab4_t0.o and 3140_concur.o).
.\Objects\Lab4.axf: Error: L6200E: Symbol current_process multiply defined (by process.o and 3140_concur.o).
.\Objects\Lab4.axf: Error: L6200E: Symbol process_queue multiply defined (by lab4_t0.o and 3140_concur.o).
.\Objects\Lab4.axf: Error: L6200E: Symbol process_queue multiply defined (by process.o and 3140_concur.o).
I really don't understand the error message.
First, I'm not sure if process.o
is referring to process.h
or process.c
(so I don't know which file to focus on). Same goes for 3140_concur.o
which has 3140_concur.c
and 3140_concur.h
.
Secondly, I'm not sure what "multiply defined" means. I figure that means I instantiate current_process
& process_queue
twice, but honestly I can't see how because I only "define" current_process
and process_queue
in process.h
:
process_t * current_process;
process_t * process_queue;
I don't even see how lab4_t0.c
could be defining process_queue
either so I'm confused by why these "multiply defined" error messages are popping up.
ALTHOUGH, I have a feeling its because in3140_concur.h
I #include "process.h"
AND in process.h
I define process_queue
and current_process
AND I also #include "3140_concur.h"
. Same goes for lab4_t0.c
(I #include "process.h"
). But the reason I do that is b/c process.c
uses methods from 3140_concur.h
and also lab4_t0.c
uses methods from from process.h
.
So if my hunch is correct, and that's the reason I'm getting the errors, how can I properly modularize my code (aka what should I #include
and not #include
) so that I don't get these errors?
If someone could type the code I need to do to remove these errors that would be great!
Note: If you were wondering why I created process.h
and why I didn't just put everything in process.h
in 3140_concur.h
file, the reason for that is that it caused errors w/ lock.c
that I don't want to go into here.
Brief summary of my code
lock.c
#include "lock.h"
extern process_t * current_process;
extern process_t * process_queue;
lock.h
#ifndef __LOCK_H_INCLUDED__
#define __LOCK_H_INCLUDED__
#include "3140_concur.h"
#include "shared_structs.h"
void l_init(lock_t* l);
void l_lock(lock_t* l);
void l_unlock(lock_t* l);
#endif /* __LOCK_H_INCLUDED */
3140_concur.c
#include "3140_concur.h"
#include <stdlib.h>
3140_concur.h
#ifndef __3140_CONCUR_H__
#define __3140_CONCUR_H__
#include <stdlib.h>
#include <fsl_device_registers.h>
#include "process.h"
void process_blocked (void);
void process_terminated (void);
unsigned int * process_stack_init (void (*f)(void), int n);
void process_stack_free (unsigned int *sp, int n);
void process_begin (void);
#endif
process.h
#include <stdlib.h>
#include <fsl_device_registers.h>
#include "3140_concur.h"
struct process_state;
typedef struct process_state process_t;
unsigned int * process_select (unsigned int * cursp);
process_t * current_process;
process_t * process_queue;
void process_start (void);
int process_create (void (*f)(void), int n);
process.c
(I do process_t* process_queue = NULL; & process_t* current_process = NULL;
b/c I want them to be NULL before any functions are called)
#include "3140_concur.h"
#include "shared_structs.h"
#include <stdlib.h>
#include <fsl_device_registers.h>
process_t* process_queue = NULL;
process_t* current_process = NULL;
lab4_t0.c
#include "process.h"
#include "utils.h"
#include "lock.h"
lock_t l;
Any help would be greatly appreciated!