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 8139397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:48:39+00:00 2026-06-06T11:48:39+00:00

I am having to rewrite an application from C++ to C. I am using

  • 0

I am having to rewrite an application from C++ to C. I am using gcc and Eclipse on Ubuntu 12.04. In doing so I have come across this error

../src/TTNoddy.c: In function ‘main’:
../src/TTNoddy.c:16:2: error: unknown type name ‘timespec’

Here is my code snippet that reproduces the problem

#include <time.h>

int main(void) {

    timespec TS;
    TS.tv_nsec = 1;

    return 0;
}

I am confused here – I am a C++ coder and never written a pure C application in my life, but the man page for clock_gettime clearly indicates that timespec is found in the time.h header file which I am including here. What have I missed?

  • 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-06-06T11:48:40+00:00Added an answer on June 6, 2026 at 11:48 am

    timespec is a struct, you need to explicitly tell the compiler this. If you carefully read the man page you can see it is stated so.

    This should work:

    #include <time.h>
    
    int main(void) {
        struct timespec TS;
        TS.tv_nsec = 1;
    
        return 0;
    }
    

    Additional note: If it had been defined as a typedef struct, you would not have needed to add the struct part manually. But, you should assume that most/all pure C structs are not defined as a typedef

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

Sidebar

Related Questions

I'm having trouble figuring out how to exclude /public/bin from this rewrite rule RewriteCond
I have a PHP-Apache application using mod_rewrite for clean URLs. I am having a
Hi I am having a little difficulty working out this mod rewrite rule /
This might not be possible but before I rewrite part of my application I
Using the following steps: (I have checked this similar post , which does not
I'm using URL Rewrite and Application Request Routing in IIS 7.5 to set up
I'm having issues with keyboard navigation in my wpf application. Simplified I have a
I have a .net 4.0 web application hosted on IIS7 server. After reading this:
I'm using Intelligencia's UrlRewriter in my application and I'm having a problem where the
(This is a rewrite of my other question ) I have a Spring WebMVC

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.