Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zones.h file incorrectly declares zones.c variables as non-extern. #9

Open
rewolff opened this issue Dec 29, 2023 · 0 comments
Open

Comments

@rewolff
Copy link

rewolff commented Dec 29, 2023

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 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant