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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:25:56+00:00 2026-06-14T09:25:56+00:00

I read this answer: Must declare function prototype in C? My question is more

  • 0

I read this answer:
Must declare function prototype in C?

My question is more specific:

In a program that uses system calls like access(), open(), creat(), write(), read()… Must I declare every system call function? Is that how C works? Because I’m getting the following:

hw1.c: In function ‘main’:
hw1.c:50:9: warning: implicit declaration of function ‘access’ [-Wimplicit-function-declaration]
hw1.c:131:9: warning: implicit declaration of function ‘lseek’ [-Wimplicit-function-declaration]
hw1.c: In function ‘writeFile’:
hw1.c:159:17: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]

Basically, it seems C is angry with every system call function I’m using.
I am somewhat new to C and this appears strange to me even though I know I have to declare functions I write I would think C would know the system call functions and would not need me to declare them explicitly in the code.

Do I need to do something like this:

int access(const char *pathname, int mode);

If so why does that make sense? I use other languages and never have to do this.

  • 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-14T09:25:57+00:00Added an answer on June 14, 2026 at 9:25 am

    Yes, you should include the correct header for every system function call you make. You don’t write the declarations yourself—you’ll get them wrong. Use the header!

    For the functions you cite, the relevant headers are:

    #include <unistd.h>  /* Many POSIX functions (but not all, by a large margin) */
    #include <fcntl.h>   /* open(), creat() - and fcntl() */
    

    See POSIX 2008 to find the correct header for other POSIX functions.

    The C99 standard requires that all functions are declared or defined before they are used.


    For your own functions, you should emulate the ‘system’. There will be a header that declares the function, the source file that implements it, and the other source files that use the function. The other source files use the header to get the declaration correct. The implementation file includes the header to make sure its implementation is consistent with what the other source files expect. So the header is the glue that holds it all together.

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

Sidebar

Related Questions

I read on this question and answer, where you must create a new DateTime
i've read this answer but i don't know how to use that sample in
I read this question but the answer does not perform a refactoring of the
I read this question in stackoverflow. The excerpt answer provided by bbum is below:
I have read this question and the simple and clear answer but it's not
My question is in relation this this answer. https://stackoverflow.com/a/8773953/1297775 I have read at many
This is a very specific question that relates to a broader question asked here:
I read this answer on SO: Because the recursive mutex has a sense of
I've read this answer about eight-five times, but there's something I'm not understanding correctly:
I just read on this answer (answer has since been removed) and I'm sure

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.