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

Related Questions

Motivation for Question : Generating 64-bit and 32-bit code requires two seperate full-program-compiles, and
I'm trying to understand what's really happening when I compile and execute C++ code,
I saw a tweet recently that confused me (this was posted by an XNA
This is a rather naive question. I'm just playing around with allocating some executable
I'm trying to compile X11R6-7.0 under Ubuntu maverick and got some weird compilation errors
I've just got confused how to implement something in a generic way in C++.
I want to install Clang compliler on my system. I went to this link
I have the following code: <rich:tabPanel switchType=client> <rich:tab name=tab1 label=tab1 onclick=alert('Hello');> ... </rich:tab> <rich:tab
I'm struggling a bit with traversing in jQuery. Here's the relevant markup: <ul id=sortable
My understanding was that arrays were simply constant pointers to a sequence of values,

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.