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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:15:52+00:00 2026-05-25T14:15:52+00:00

Is an ANSI C-compliant implementation allowed to include additional types and functions in its

  • 0

Is an ANSI C-compliant implementation allowed to include additional types and functions in its standard library, beyond those enumerated by the standard? (An ideal answer would reference the relevant part of the ANSI standard.)

I ask particularly because Mac OS 10.7 declares the getline function in stdio.h, even when compiling with gcc or clang using the -ansi flag. This breaks several older programs that define their own getline function. Is this a fault of Mac OS 10.7? (The man page for getline on Mac OS 10.7 says that getline conforms to the POSIX.1 standard, which came in 2008.)

Edit: To clarify, I find it odd that including stdio.h in an ANSI C89 program on Mac OS 10.7 also pulls in the declaration for the getline function, since getline is not one of the functions enumerated in the K&R (and presumably ANSI) description of stdio.h. In particular, attempting to compile noweb:

gcc -ansi -pedantic    -c -o notangle.o notangle.c
In file included from notangle.nw:28:
getline.h:4: error: conflicting types for ‘getline’
/usr/include/stdio.h:449: error: previous declaration of ‘getline’ was here

Is it a bug in Mac OS 10.7 includes the declaration of getline in stdio.h even when compiling for the ANSI C89 standard?

  • 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-25T14:15:53+00:00Added an answer on May 25, 2026 at 2:15 pm

    From section 7.1.3 paragraph 2 of n1570 (which is a draft of C1x):

    No other identifiers are reserved.

    This is the part that means getline shouldn’t be defined by the <stdio.h>, since it’s not a reserved identifier according to the spec. So if your library defines getline in <stdio.h>, it’s not technically compliant with the C standard…

    However, you should be able to use the feature test macros to cause getline to be undefined in <stdio.h>.

    #undef _POSIX_C_SOURCE
    #define _POSIX_C_SOURCE 200112L
    #include <stdio.h>
    

    This will give you only the definitions from the older POSIX standards. This won’t work on some GNU C++ implementations, which is ExTrEmeLY fruSTRaTiNG for some folks.

    The relevant section of the manpage is (taken from a glibc manpage, sorry…)

       Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
    
           getline(), getdelim():
               Since glibc 2.10:
                   _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
               Before glibc 2.10:
                   _GNU_SOURCE
    

    This part of the manpage tells you which macros need to be defined to which values in order to get the definition. My bet is that _POSIX_C_SOURCE is already defined by your compiler to 200809L.

    The idea of feature test macros is that if you define your macros, like _POSIX_C_SOURCE, _BSD_SOURCE, _XOPEN_SOURCE, etc. to the values you want, you won’t need to worry about new library functions clashing with your existing functions. There is also _GNU_SOURCE, which turns everything on if you use glibc, but I suggest giving that macro a wide berth.

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

Sidebar

Related Questions

I am working with a SQL Library (Programming library, ANSI SQL Compliant, called ABS
This is an ANSI C question. I have the following code. #include <stdio.h> #include
When storing latitude or longitude data in an ANSI SQL compliant database, what datatype
I have a nice clean standards-compliant codebase that I can compile with GCC's -ansi
I've the follwing 2 versions of ANSI compliant SQL(column/table names changed to protect confidential
Does the ANSI standard mandate the logical operators to be short-circuited, in either C
I am taking a c++ course at school and need an ANSI compliant compiler,
It seems ANSI C 89 is the best choise for writing a cross-platform library
Is there a standards-complaint method to represent a byte in ANSI (C89/90) C? I
In ANSI C++, how can I assign the cout stream to a variable name?

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.