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 79k
  • Answers 79k
  • 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
  • Editorial Team
    Editorial Team added an answer Your custom ItemRenderers should not register an event listener with… May 11, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer You cannot directly fire base class events. This is exactly… May 11, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer Since the previous answers don't appear to work in with… May 11, 2026 at 4:05 pm

Related Questions

Important: This question is getting quite long, if this is the first time you're
Using VS2008, I am trying to add an App_Code folder from add-->folder-->Add ASP_NET folder.
At school we have been using a bootstrap program to run stand-alone programs without
I am comparing the two base classes of each namespace and am a bit

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.