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

  • Home
  • SEARCH
  • 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 85593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:06:49+00:00 2026-05-10T22:06:49+00:00

I am a bit confused why this code compiles. I leave out the necessary

  • 0

I am a bit confused why this code compiles. I leave out the ‘necessary’ #include <OpenGL/gl.h> and still the program can compile. How is this possible when my program is calling functions from the GL library, without including them.

int main(int argc, char** argv) {      glClearColor(1.0,1.0,1.0,1.0);     return 0; } 

I use this compilation command:

 gcc -framework GLUT -framework OpenGL test.c 

I was under the assumption that adding -framework just specifies to the linker where the library is, but I thought I still need the headers?

  • 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. 2026-05-10T22:06:50+00:00Added an answer on May 10, 2026 at 10:06 pm

    In C (prior to C99), you don’t have to declare functions in order to use them. The compiler will assume the function takes the promoted parameter types you pass to it, and assume the function returns an int. This, however can be quite problematic, and behavior is undefined if the function doesn’t. Let’s look at this:

    /* file1.c */ void foo(char a, char b) {     /* doing something ... */ }  /* main.c */ int main(void) {     char a = 'a', b = 'b';     /* char variables are promoted to int         before being passed */     foo(b, a);  } 

    Because the types are being promoted (char -> int, float -> double) if there is no declaration of the function at the time you call it, the arguments could not be passed at the right places in memory anymore. Accessing b can yield to a curious value of the parameter. As a side node, the same problem occurs when you pass arguments to vararg functions like prinft, or functions having no prototype (like void f(), where there is no information about the parameters types and count). This is the reason that you always have to access variadic arguments with va_arg using their promoted type. GCC will warn you if you don’t.

    Always include the proper header files, so you don’t run into this problems.

    Edit: thanks to Chris for pointing out that char literals (like 'a') are always of type int in C

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

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer If you know the angle of the red line for… May 11, 2026 at 10:51 am
  • added an answer It is undefined behavior. In the first line you define… May 11, 2026 at 10:51 am
  • added an answer Broadcasting is liable to be filtered out by certain equipment.… May 11, 2026 at 10:51 am

Related Questions

I am a bit confused why this code compiles. I leave out the necessary
I am a bit confused about socket programming in C. You create a socket,
You guys were very helpful yesterday. I am still a bit confused here though.
I am a bit rusty on my Haskell and am looking to ramp back
I am a bit of an ant newbie, and I'm having trouble making a
I am a bit new to Perl, but here is what I want to
I am a bit stuck on the design of my seo friendly urls for
I am a bit stunned by lots of reactions on questions that point out
I am comparing the two base classes of each namespace and am a bit
This is my very first question so I am a bit nervous about it

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.