1

I downloaded several versions of glibc namely 2.18, 2.19, 2.20, 2.23 and am trying to find the file iso646.h but cannot find it. I thought it was a standard part of glibc so it should be there. Anyone know why it isn't there?

I have, however, found it on my local machine in the /usr/lib/gcc directory. So Im assuming it was installed with gcc. But I still don't know why I cant find it in the glibc sources. I'm pasting the contents of the one I found below:

/* Copyright (C) 1997-2014 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ /* * ISO C Standard: 7.9 Alternative spellings <iso646.h> */ #ifndef _ISO646_H #define _ISO646_H #ifndef __cplusplus #define and && #define and_eq &= #define bitand & #define bitor | #define compl ~ #define not ! #define not_eq != #define or || #define or_eq |= #define xor ^ #define xor_eq ^= #endif #endif 

Edit: The only file I found (which kinda resembles iso646.h) in each of the glibc sources I downloaded(from gnu.org) was conform/data/iso646.h-data which looks like this:

#if !defined ISO && !defined POSIX && !defined XPG3 && !defined XPG4 macro and macro and_eq macro bitand macro bitor macro compl macro not macro not_eq macro or macro or_eq macro xor macro xor_eq #if !defined ISO && !defined ISO99 && !defined ISO11 allow *_t #endif #endif 

But since I dont how macro is defined here, or where it is defined, this file is incomprehensible to me.

2
  • have you checked the path glibc/conform/data/iso646.h-data Commented May 23, 2016 at 8:28
  • @piyushjaiswal Yes I actually looked in the glibc/conform/data/iso646.h file before I asked my question, but since I didn't know how macro was defined, or in what file macro was defined in, I couldnt understand that file and didn't bother including it in the question. Please see the EDIT section I added to my question. Commented May 23, 2016 at 9:39

3 Answers 3

7

The file is not part of libc, but the compiler.

https://gcc.gnu.org/onlinedocs/gccint/Headers.html

$ find /|grep iso646.h /usr/lib/gcc/x86_64-linux-gnu/4.8/include/iso646.h /usr/lib/gcc/x86_64-linux-gnu/4.6/include/iso646.h 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the link. Didn't know gcc includes its own headers when compiling programs. But as per [link]en.wikipedia.org/wiki/C_standard_library the file iso646.h has been a part of the libc standard since 1995.... do you know the reason why glibc doesn't include it?
@jerry: See my answer. "The implementation" is the combination of the compiler and the library, and there are headers that the compiler maintainers have an easier time providing than the library maintainers.
Thanks @DevSolar +1 didnt know this agreement between library and compiler maintainers existed. Since I downloaded the glibc source directly from gnu.org and they dont include iso646.h at all in glibc, does this mean that the glibc maintainers will always assume that gcc will ALWAYS include it?
4

In elaboration of Stian's answer on those files being part of the compiler, and where to find them:


There are various standard headers that are part of a so-called "freestanding implementation". They do #define and typedef only, and do not declare any actual functions; in other words, they are "header only" without any linkable code:

  • <float.h>
  • <iso646.h>
  • <limits.h>
  • <stdalign.h>
  • <stdarg.h>
  • <stdbool.h>
  • <stddef.h>
  • <stdint.h>
  • <stdnoreturn.h>

It is quite possible, in some places even easier, to have these defined by the compiler instead of the library, because the compiler knows everything about its platform and the types it uses, their encoding, limits, stack layout and how to do variable argument lists, etc.

The compiler can provide the "correct" implementation for these headers without requiring any additional preprocessor "magic", which would be necessary if these headers were defined by the library.

3 Comments

Rather, the mentioned headers must be supported by all implementations (compilers), no matter if freestanding (embedded systems etc) or hosted (running on top of an OS).
@Lundin: The freestanding implementation is specifically defined as a subset of the hosted implementation. And implementation != compiler, implementation == (compiler + library).
Not really, they are different and have different rules for main etc. I believe you refer to 4/6: "The two forms of conforming implementation are hosted and freestanding. A conforming hosted implementation shall accept any strictly conforming program. A conforming freestanding implementation shall accept any strictly conforming program in which the use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers..." And then follows the list in your answer. So far you could say that freestanding is a subset, as far as headers go.
2

As an added to Stian's answer, another way to find locations is using gcc -E

/* demo.c */

#include <iso646.h> int main(void) { return 0; } 

Launch:

david@debian:~$ gcc -E demo.c # 1 "demo.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 1 "<command-line>" 2 # 1 "demo.c" # 1 "/usr/lib/gcc/x86_64-linux-gnu/4.9/include/iso646.h" 1 3 4 # 2 "demo.c" 2 int main(void) { return 0; } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.