Jon Wilder
Active Member
I've always been taught that the typical practice for external functions shared across modules is to define in source files and declare in header files. However, I have a struct that I'm trying to share across modules, and the only way I've been able to make the compiler not complain is to define the struct in the header file, then declare the struct in the source files.
When I instead try to do -
This does not work.
Can anyone explain why?
Code:
/* midi.h */
struct MIDI {
uint8_t buffer, controller, value;
bool controller_received:1, status_valid:1; program_change:1, control_change:1, data_ready:1, store:1, mute:1, channel_select:1;
};
Code:
/* midi.c */
#include <at89s8253.h>
#include <stdint.h>
#include <stdbool.h>
#include "main.h"
#include "midi.h"
extern struct MIDI midi;
void receiveSerial() __interrupt(SI0_VECTOR) __using 1 {
/* Rest of code */
}
Code:
/* main.c*/
#include <at89s8253.h>
#include <stdint.h>
#include <stdbool.h>
#include "main.h"
#include "midi.h"
extern struct MIDI midi;
void main() {
/* Main Function */
}
When I instead try to do -
Code:
/* midi.c */
#include <at89s8253.h>
#include <stdint.h>
#include <stdbool.h>
#include "main.h"
#include "midi.h"
struct MIDI {
uint8_t buffer, controller, value;
bool controller_received:1, status_valid:1; program_change:1, control_change:1, data_ready:1, store:1, mute:1, channel_select:1;
};
void receiveSerial __interrupt(SI0_VECTOR) __using 1 {
struct MIDI midi;
/* Rest of code */
}
Code:
/* midi.h */
struct MIDI;
Code:
/* main.c */
#include <at89s8253.h>
#include <stdint.h>
#include <stdbool.h>
#include "main.h"
#include "midi.h"
extern struct MIDI midi;
void main() {
/* Main Function */
}
This does not work.
Can anyone explain why?
Last edited: