Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 583119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:45:33+00:00 2026-05-13T14:45:33+00:00

This is a cut down example of a much larger project. You can see

  • 0

This is a cut down example of a much larger project. You can see it here.

I have a header file containing the limits of the system time functions. Call it time_config.h.

#ifndef TIME_CONFIG_H
#define TIME_CONFIG_H

#define HAS_TIMEGM

#define SYSTEM_LOCALTIME_MAX             2147483647
#define SYSTEM_LOCALTIME_MIN            -2147483648
#define SYSTEM_GMTIME_MAX                2147483647
#define SYSTEM_GMTIME_MIN               -2147483648
const struct tm SYSTEM_MKTIME_MAX = { 7, 14, 19, 18, 0, 138, 0, 0, 0, 0, 0 };
const struct tm SYSTEM_MKTIME_MIN = { 52, 45, 12, 13, 11, 1, 0, 0, 0, 0, 0 };

#endif

Then there’s a header file defining my time functions. Call it mytime.h. It includes time_config.h.

#ifndef MYTIME_H
#define MYTIME_H

#include "time_config.h"

#ifndef HAS_TIMEGM
time_t timegm(const struct tm*);
#endif

#endif

There’s mytime.c which includes mytime.h and defines timegm(), if necessary.

I compile it into an object file…

gcc <a lot of warning flags> -I. -c -o mytime.o mytime.c

And link that into a test binary, t/year_limit.t.c also includes mytime.h.

gcc <a lot of warning flags> -I. mytime.o t/year_limit.t.c -o t/year_limit.t

Which errors out with:

ld: duplicate symbol _SYSTEM_MKTIME_MAX in /var/folders/eJ/eJzTVP7oG7GVsKYHJtMprE+++TI/-Tmp-//ccMe5DXb.o and mytime.o
collect2: ld returned 1 exit status

Because time_config.h is generated during the build process by a probe of the system, it would be very convenient to keep all the values together in one header file, or even multiple header files. Altering the .c file during the build process is more difficult.

It works fine without the structs. How do I declare the min/max date structs in a header file without causing this clash? Or am I compiling and linking incorrectly?

PS This is ANSI C89.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:45:33+00:00Added an answer on May 13, 2026 at 2:45 pm
    const struct tm SYSTEM_MKTIME_MAX = { 7, 14, 19, 18, 0, 138, 0, 0, 0, 0, 0 };
    

    The above declares and defines the object SYSTEM_MKTIME_MAX; Multiple inclusions of the header leads to multiple definitions.

    Put in an extern in the header and put the definition in the implementation file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found this example on StackOverflow: var people = new List<Person> { new
I've created a stored procedure similar to the one below (I'm using this cut
I am using this command: cut -d: -f2 To sort and reedit text, Is
I'll be the first to admit that this is cut and past programming. I've
This is a bit of a long shot, but if anyone can figure it
This is my first post here and I wanted to get some input from
For some time I've noticed how much the File Open and File save dialogs
I have a route in my asp.net mvc 2 site that looks like this
I have a simple applet on a web page like this. (This is a
This is beyond both making sense and my control. That being said here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.