utz
utz copied to clipboard
Zones.h file incorrectly declares zones.c variables as non-extern.
To get the declarations of the zones you need to include zones.h
Without the "extern" in front of the declarations, the compiler will declare the variables and then fill them with zeroes if you forget to add "zones.c" to the required sources. My project uses "cmake" with which I am not very familar, and turns out I had forgotten to include it. Because the compiler was "happy" with the empty zero-initialized variables, the runtime errors (only on my embedded system with the missing zones.c) were very confusing and hard-to-debug.
I've added my timezone alias "Amsterdam" to the tables, so my numbers are off from yours. So this diff will not apply as shown here.
diff --git a/zones.h b/zones.h
index bfa2835..708c09a 100644
--- a/zones.h
+++ b/zones.h
@@ -1,8 +1,8 @@
#ifndef _ZONES_H
#define _ZONES_H
-const urule_packed_t zone_rules[50];
-const char zone_abrevs[209];
+extern const urule_packed_t zone_rules[50];
+extern const char zone_abrevs[209];
#define MAX_ABREV_FORMATTER_LEN 7
@@ -111,5 +111,5 @@ const uzone_packed_t zone_defns[46];
#define NUM_ZONE_NAMES 100
#define MAX_ZONE_NAME_LEN 17
-const unsigned char zone_names[972];
+extern const unsigned char zone_names[972];
#endif /* _ZONES_H */