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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:24:11+00:00 2026-05-23T08:24:11+00:00

After some talking about linking in ##C on irc.freenode.net, I went to test some

  • 0

After some talking about linking in ##C on irc.freenode.net, I went to test some concepts I learned, and came up with this situation.

I have this file, named main.c:

int main(void) {
    func();

    return 0;
}

And this file, named test.c:

#include <stdio.h>

void func(void) {
    printf("Hello.\n");
}

There’s no test.h file.

I do this:

$ gcc -c main.c
$ gcc -c test.c
$ gcc main.o test.o
$ ./a.out
Hello.
$

and that works. Shouldn’t gcc complain, on its first call, about not knowing function func() that is called in the main.c file? I didn’t include any file with its prototype or implementation, and yet gcc can compile an object code and make a sane executable. What happened there that I’m missing?

Thank you.

  • 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-23T08:24:12+00:00Added an answer on May 23, 2026 at 8:24 am

    Turn on a few warnings and you will be made painfully aware of the problems.

    > gcc -Wall -c main.c
    main.c: In function ‘main’:
    main.c:2:5: warning: implicit declaration of function ‘func’
    

    C will by default assume things about unknown functions. Good? Probably not. Historical.

    Also gcc -std=c99 will throw the warning as well.

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

Sidebar

Related Questions

After some stupid musings about Klingon languages, that came from this post I began
After some find and replace refactoring I ended up with this gem: const class
After some time I wanted to update my git repo, and then something went
The entities and mappings I'm talking about in this question can be found here
I have been doing some research about this and have found a few similar
After some years of experience in the field, it seems to me that the
After some tweaking of some code I got from someone to cause a characters
After some experience with functional languages, I'm starting to use recursion more in Java
After some code review I removed unnecessary properties which resulted in empty rules. So
after some advice regarding a problem i am getting using a linux based piece

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.