Skip to content

Commit

Permalink
Fix build failure due to "multiple definition" errors
Browse files Browse the repository at this point in the history
The USB descriptor variables were effectively being declared twice--once
in usb_descriptors.c and once in usb_core.c--because both files included
usb_descriptors.h, where those variables were originally declared
without the "extern" keyword. Because of this, GCC refused to link the
object files. After declaring the variables as "extern", the build
finishes without issue.
  • Loading branch information
cyrozap committed Mar 4, 2021
1 parent e2c8265 commit ab23849
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions usb_descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef enum {
usb_string_index_last,
} __attribute__ ((packed)) usb_string_index_t;

const usb_string_descriptor_t *usb_string_descriptors[usb_string_index_last];
extern const usb_string_descriptor_t *usb_string_descriptors[usb_string_index_last];

/* Endpoints */

Expand All @@ -55,7 +55,7 @@ enum {

/* Device Descriptor */

const usb_device_descriptor_t usb_device_descriptor;
extern const usb_device_descriptor_t usb_device_descriptor;

/* Configuration Descriptor */

Expand Down Expand Up @@ -93,6 +93,6 @@ typedef struct {
usb_endpoint_descriptor_t data_eptx_2;
} __attribute__((packed)) usb_device_configuration_descriptor_t;

const usb_device_configuration_descriptor_t usb_configuration_descriptor;
extern const usb_device_configuration_descriptor_t usb_configuration_descriptor;

#endif /* USB_DESCRIPTORS_H */

0 comments on commit ab23849

Please sign in to comment.