Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #162773 > unrolled thread

How to print gcc include path using C?

Started byThiago Adams <thiago.adams@gmail.com>
First post2021-09-20 11:48 -0700
Last post2021-09-21 23:05 +0000
Articles 17 — 7 participants

Back to article view | Back to comp.lang.c


Contents

  How to print gcc include path using C? Thiago Adams <thiago.adams@gmail.com> - 2021-09-20 11:48 -0700
    Re: How to print gcc include path using C? Bart <bc@freeuk.com> - 2021-09-20 20:45 +0100
      Re: How to print gcc include path using C? Thiago Adams <thiago.adams@gmail.com> - 2021-09-20 12:55 -0700
        Re: How to print gcc include path using C? scott@slp53.sl.home (Scott Lurndal) - 2021-09-20 21:53 +0000
          Re: How to print gcc include path using C? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-20 17:54 -0700
            Re: How to print gcc include path using C? Thiago Adams <thiago.adams@gmail.com> - 2021-09-21 05:07 -0700
              Re: How to print gcc include path using C? scott@slp53.sl.home (Scott Lurndal) - 2021-09-21 14:00 +0000
              Re: How to print gcc include path using C? Mark Bluemel <mark.bluemel@gmail.com> - 2021-09-21 07:07 -0700
              Re: How to print gcc include path using C? antispam@math.uni.wroc.pl - 2021-09-21 14:08 +0000
                Re: How to print gcc include path using C? Thiago Adams <thiago.adams@gmail.com> - 2021-09-21 12:01 -0700
                  Re: How to print gcc include path using C? gazelle@shell.xmission.com (Kenny McCormack) - 2021-09-21 20:13 +0000
                  Re: How to print gcc include path using C? scott@slp53.sl.home (Scott Lurndal) - 2021-09-21 20:17 +0000
                    Re: How to print gcc include path using C? gazelle@shell.xmission.com (Kenny McCormack) - 2021-09-21 20:35 +0000
                      Re: How to print gcc include path using C? scott@slp53.sl.home (Scott Lurndal) - 2021-09-21 21:30 +0000
                    Re: How to print gcc include path using C? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-21 13:37 -0700
                      Re: How to print gcc include path using C? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-21 14:07 -0700
                  Re: How to print gcc include path using C? antispam@math.uni.wroc.pl - 2021-09-21 23:05 +0000

#162773 — How to print gcc include path using C?

FromThiago Adams <thiago.adams@gmail.com>
Date2021-09-20 11:48 -0700
SubjectHow to print gcc include path using C?
Message-ID<495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
How to print gcc include path ?

I tried with no success:

const char* s = getenv("C_INCLUDE_PATH");
printf("C_INCLUDE_PATH  :%s\n", (s != NULL) ? s : "getenv returned NULL");
printf("end test\n");

[toc] | [next] | [standalone]


#162776

FromBart <bc@freeuk.com>
Date2021-09-20 20:45 +0100
Message-ID<siaoc8$1n4$1@dont-email.me>
In reply to#162773
On 20/09/2021 19:48, Thiago Adams wrote:
> How to print gcc include path ?
> 
> I tried with no success:
> 
> const char* s = getenv("C_INCLUDE_PATH");
> printf("C_INCLUDE_PATH  :%s\n", (s != NULL) ? s : "getenv returned NULL");
> printf("end test\n");
> 


I get the same on my Windows machine. The reason was because 
C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc.

I think this is something that you define yourself, and it affects how 
gcc works. I think it just adds to the set of -I paths.

[toc] | [prev] | [next] | [standalone]


#162777

FromThiago Adams <thiago.adams@gmail.com>
Date2021-09-20 12:55 -0700
Message-ID<d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
In reply to#162776
On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote:
> On 20/09/2021 19:48, Thiago Adams wrote: 
> > How to print gcc include path ? 
> > 
> > I tried with no success: 
> > 
> > const char* s = getenv("C_INCLUDE_PATH"); 
> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
> > printf("end test\n"); 
> >
> I get the same on my Windows machine. The reason was because 
> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
> 
> I think this is something that you define yourself, and it affects how 
> gcc works. I think it just adds to the set of -I paths.

On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt)
using:

int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env));

I would like to do the same for gcc/clang on linux.











[toc] | [prev] | [next] | [standalone]


#162781

Fromscott@slp53.sl.home (Scott Lurndal)
Date2021-09-20 21:53 +0000
Message-ID<dp72J.43028$md6.29046@fx36.iad>
In reply to#162777
Thiago Adams <thiago.adams@gmail.com> writes:
>On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote:
>> On 20/09/2021 19:48, Thiago Adams wrote: 
>> > How to print gcc include path ? 
>> > 
>> > I tried with no success: 
>> > 
>> > const char* s = getenv("C_INCLUDE_PATH"); 
>> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
>> > printf("end test\n"); 
>> >
>> I get the same on my Windows machine. The reason was because 
>> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
>> 
>> I think this is something that you define yourself, and it affects how 
>> gcc works. I think it just adds to the set of -I paths.
>
>On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt)
>using:
>
>int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env));
>
>I would like to do the same for gcc/clang on linux.

Sorry, no can do.   The search paths are built-in (/usr/include,
/gcc-installation-path/include, et alia)
and additional paths are specified via -I to the compiler
by the programmer.

You can use 'gcc -H' to get a list of paths for each included
file during compilation time.

[toc] | [prev] | [next] | [standalone]


#162788

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-09-20 17:54 -0700
Message-ID<87y27qoiip.fsf@nosuchdomain.example.com>
In reply to#162781
scott@slp53.sl.home (Scott Lurndal) writes:
> Thiago Adams <thiago.adams@gmail.com> writes:
>>On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote:
>>> On 20/09/2021 19:48, Thiago Adams wrote: 
>>> > How to print gcc include path ? 
>>> > 
>>> > I tried with no success: 
>>> > 
>>> > const char* s = getenv("C_INCLUDE_PATH"); 
>>> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
>>> > printf("end test\n"); 
>>> >
>>> I get the same on my Windows machine. The reason was because 
>>> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
>>> 
>>> I think this is something that you define yourself, and it affects how 
>>> gcc works. I think it just adds to the set of -I paths.
>>
>>On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt)
>>using:
>>
>>int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env));
>>
>>I would like to do the same for gcc/clang on linux.
>
> Sorry, no can do.   The search paths are built-in (/usr/include,
> /gcc-installation-path/include, et alia)
> and additional paths are specified via -I to the compiler
> by the programmer.

And gcc uses several environment variables to allow the user to
supplement the directories searched by gcc's built-in definitions and by
any -I options.  See the gcc documentation for details.

The $C_INCLUDE_PATH environment variable is not normally set.

> You can use 'gcc -H' to get a list of paths for each included
> file during compilation time.

https://stackoverflow.com/a/6666338/827263

    gcc -xc -E -v - </dev/null

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#162793

FromThiago Adams <thiago.adams@gmail.com>
Date2021-09-21 05:07 -0700
Message-ID<8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>
In reply to#162788
On Monday, September 20, 2021 at 9:54:29 PM UTC-3, Keith Thompson wrote:
> sc...@slp53.sl.home (Scott Lurndal) writes: 
> > Thiago Adams <thiago...@gmail.com> writes: 
> >>On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote: 
> >>> On 20/09/2021 19:48, Thiago Adams wrote: 
> >>> > How to print gcc include path ? 
> >>> > 
> >>> > I tried with no success: 
> >>> > 
> >>> > const char* s = getenv("C_INCLUDE_PATH"); 
> >>> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
> >>> > printf("end test\n"); 
> >>> > 
> >>> I get the same on my Windows machine. The reason was because 
> >>> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
> >>> 
> >>> I think this is something that you define yourself, and it affects how 
> >>> gcc works. I think it just adds to the set of -I paths. 
> >> 
> >>On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt) 
> >>using: 
> >> 
> >>int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env)); 
> >> 
> >>I would like to do the same for gcc/clang on linux. 
> > 
> > Sorry, no can do. The search paths are built-in (/usr/include, 
> > /gcc-installation-path/include, et alia) 
> > and additional paths are specified via -I to the compiler 
> > by the programmer.
> And gcc uses several environment variables to allow the user to 
> supplement the directories searched by gcc's built-in definitions and by 
> any -I options. See the gcc documentation for details. 
> 
> The $C_INCLUDE_PATH environment variable is not normally set.
> > You can use 'gcc -H' to get a list of paths for each included 
> > file during compilation time.
> https://stackoverflow.com/a/6666338/827263 
> 
> gcc -xc -E -v - </dev/null 
> 

I run the command this is the include part:

 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include

Can I use this "hardcoded" and expect to work in any linux?
 /usr/include (stdlib.h is here for instance)

In windows we can have many versions of SDK, compilers..so to select 
one we can use the "Visual Studio Command prompt 2017"  or
"Visual Studio Command prompt 2019" etc.
For gcc linux it seems that there is always one "default" pre-configured.


(My use case is to use the same include path of gcc inside my c to c compiler 
so the user does not need to inform -Ipath for each standard path)

[toc] | [prev] | [next] | [standalone]


#162794

Fromscott@slp53.sl.home (Scott Lurndal)
Date2021-09-21 14:00 +0000
Message-ID<Qzl2J.13648$d82.6031@fx21.iad>
In reply to#162793
Thiago Adams <thiago.adams@gmail.com> writes:
>On Monday, September 20, 2021 at 9:54:29 PM UTC-3, Keith Thompson wrote:
>> sc...@slp53.sl.home (Scott Lurndal) writes: 
>> > Thiago Adams <thiago...@gmail.com> writes: 
>> >>On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote: 
>> >>> On 20/09/2021 19:48, Thiago Adams wrote: 
>> >>> > How to print gcc include path ? 
>> >>> > 
>> >>> > I tried with no success: 
>> >>> > 
>> >>> > const char* s = getenv("C_INCLUDE_PATH"); 
>> >>> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
>> >>> > printf("end test\n"); 
>> >>> > 
>> >>> I get the same on my Windows machine. The reason was because 
>> >>> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
>> >>> 
>> >>> I think this is something that you define yourself, and it affects how 
>> >>> gcc works. I think it just adds to the set of -I paths. 
>> >> 
>> >>On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt) 
>> >>using: 
>> >> 
>> >>int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env)); 
>> >> 
>> >>I would like to do the same for gcc/clang on linux. 
>> > 
>> > Sorry, no can do. The search paths are built-in (/usr/include, 
>> > /gcc-installation-path/include, et alia) 
>> > and additional paths are specified via -I to the compiler 
>> > by the programmer.
>> And gcc uses several environment variables to allow the user to 
>> supplement the directories searched by gcc's built-in definitions and by 
>> any -I options. See the gcc documentation for details. 
>> 
>> The $C_INCLUDE_PATH environment variable is not normally set.
>> > You can use 'gcc -H' to get a list of paths for each included 
>> > file during compilation time.
>> https://stackoverflow.com/a/6666338/827263 
>> 
>> gcc -xc -E -v - </dev/null 
>> 
>
>I run the command this is the include part:
>
> /usr/lib/gcc/x86_64-linux-gnu/7/include
> /usr/local/include
> /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
> /usr/include/x86_64-linux-gnu
> /usr/include
>
>Can I use this "hardcoded" and expect to work in any linux?
> /usr/include (stdlib.h is here for instance)

Not completely.   You can probably legitimately assume that
/usr/include is part of the list.   And maybe /usr/local/include,
but the gcc ones are specific to teh major version of the compiler
which in your case is GCC7.

[toc] | [prev] | [next] | [standalone]


#162795

FromMark Bluemel <mark.bluemel@gmail.com>
Date2021-09-21 07:07 -0700
Message-ID<025fe88c-0667-4703-9d28-d8478e3c1cd5n@googlegroups.com>
In reply to#162793
On Tuesday, 21 September 2021 at 13:07:41 UTC+1, Thiago Adams wrote:
> On Monday, September 20, 2021 at 9:54:29 PM UTC-3, Keith Thompson wrote: 
> > sc...@slp53.sl.home (Scott Lurndal) writes: 
> > > Thiago Adams <thiago...@gmail.com> writes: 
> > >>On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote: 
> > >>> On 20/09/2021 19:48, Thiago Adams wrote: 
> > >>> > How to print gcc include path ? 
> > >>> > 
> > >>> > I tried with no success: 
> > >>> > 
> > >>> > const char* s = getenv("C_INCLUDE_PATH"); 
> > >>> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
> > >>> > printf("end test\n"); 
> > >>> > 
> > >>> I get the same on my Windows machine. The reason was because 
> > >>> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
> > >>> 
> > >>> I think this is something that you define yourself, and it affects how 
> > >>> gcc works. I think it just adds to the set of -I paths. 
> > >> 
> > >>On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt) 
> > >>using: 
> > >> 
> > >>int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env)); 
> > >> 
> > >>I would like to do the same for gcc/clang on linux. 
> > > 
> > > Sorry, no can do. The search paths are built-in (/usr/include, 
> > > /gcc-installation-path/include, et alia) 
> > > and additional paths are specified via -I to the compiler 
> > > by the programmer. 
> > And gcc uses several environment variables to allow the user to 
> > supplement the directories searched by gcc's built-in definitions and by 
> > any -I options. See the gcc documentation for details. 
> > 
> > The $C_INCLUDE_PATH environment variable is not normally set. 
> > > You can use 'gcc -H' to get a list of paths for each included 
> > > file during compilation time. 
> > https://stackoverflow.com/a/6666338/827263 
> > 
> > gcc -xc -E -v - </dev/null 
> >
> I run the command this is the include part: 
> 
> /usr/lib/gcc/x86_64-linux-gnu/7/include 
> /usr/local/include 
> /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed 
> /usr/include/x86_64-linux-gnu 
> /usr/include 
> 
> Can I use this "hardcoded" and expect to work in any linux? 
> /usr/include (stdlib.h is here for instance) 
> 
> In windows we can have many versions of SDK, compilers..so to select 
> one we can use the "Visual Studio Command prompt 2017" or 
> "Visual Studio Command prompt 2019" etc. 
> For gcc linux it seems that there is always one "default" pre-configured. 
> 
> 
> (My use case is to use the same include path of gcc inside my c to c compiler 
> so the user does not need to inform -Ipath for each standard path)

Have you considered researching GCC specifics in a suitable place?
While many people here may be GCC users, it's an open question whether many are GCC experts - in most cases you don't need to know much about GCC internals to use it.
<https://gcc.gnu.org/wiki> may help, and gives details of a mailing list specifically for GCC questions.

[toc] | [prev] | [next] | [standalone]


#162796

Fromantispam@math.uni.wroc.pl
Date2021-09-21 14:08 +0000
Message-ID<sicp12$4ia$1@z-news.wcss.wroc.pl>
In reply to#162793
Thiago Adams <thiago.adams@gmail.com> wrote:
> On Monday, September 20, 2021 at 9:54:29 PM UTC-3, Keith Thompson wrote:
> > sc...@slp53.sl.home (Scott Lurndal) writes: 
> > > Thiago Adams <thiago...@gmail.com> writes: 
> > >>On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote: 
> > >>> On 20/09/2021 19:48, Thiago Adams wrote: 
> > >>> > How to print gcc include path ? 
> > >>> > 
> > >>> > I tried with no success: 
> > >>> > 
> > >>> > const char* s = getenv("C_INCLUDE_PATH"); 
> > >>> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
> > >>> > printf("end test\n"); 
> > >>> > 
> > >>> I get the same on my Windows machine. The reason was because 
> > >>> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
> > >>> 
> > >>> I think this is something that you define yourself, and it affects how 
> > >>> gcc works. I think it just adds to the set of -I paths. 
> > >> 
> > >>On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt) 
> > >>using: 
> > >> 
> > >>int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env)); 
> > >> 
> > >>I would like to do the same for gcc/clang on linux. 
> > > 
> > > Sorry, no can do. The search paths are built-in (/usr/include, 
> > > /gcc-installation-path/include, et alia) 
> > > and additional paths are specified via -I to the compiler 
> > > by the programmer.
> > And gcc uses several environment variables to allow the user to 
> > supplement the directories searched by gcc's built-in definitions and by 
> > any -I options. See the gcc documentation for details. 
> > 
> > The $C_INCLUDE_PATH environment variable is not normally set.
> > > You can use 'gcc -H' to get a list of paths for each included 
> > > file during compilation time.
> > https://stackoverflow.com/a/6666338/827263 
> > 
> > gcc -xc -E -v - </dev/null 
> > 
> 
> I run the command this is the include part:
> 
>  /usr/lib/gcc/x86_64-linux-gnu/7/include
>  /usr/local/include
>  /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
>  /usr/include/x86_64-linux-gnu
>  /usr/include
> 
> Can I use this "hardcoded" and expect to work in any linux?
>  /usr/include (stdlib.h is here for instance)

In case you missed it: 7 in '/usr/lib/gcc/x86_64-linux-gnu/7/include'
is version number, so will be different for different gcc versions.
'x86_64-linux-gnu' is platform name, on different platform like
ARM it will be different.

Also note that 'gcc' paths are gcc-internal.  So they will point
to pleace where gcc lives.  "Standard" gcc files are installed
in '/usr/lib', but there may be nostandard instalation say
in '/usr/local/lib' or in subdirectory of '/opt' (or inside
private user directory.

> In windows we can have many versions of SDK, compilers..so to select 
> one we can use the "Visual Studio Command prompt 2017"  or
> "Visual Studio Command prompt 2019" etc.
> For gcc linux it seems that there is always one "default" pre-configured.

Not "always": you need to install it.  But you can instal non-default
compilers and they will peacefully co-exist.  On my machine I have
few different versions of 'arm-none-eabi-gcc', each in it own directory
tree.  When I invoke any of them using its full path each compiler
picks its own header files.

> (My use case is to use the same include path of gcc inside my c to c compiler 
> so the user does not need to inform -Ipath for each standard path)

It is not clear what your "c to c compiler" is supposed to do.
Gcc and Linux paradigm is that there are few compiler supplied headers
and separate system headers.  In Linux "system" headers used to be
in '/usr/include'.  Multiarch system moved several headers to
'/usr/include/platform' where platform is something like
'i386-linux-gnu'.  However, gcc can work as cross-compiler and
in such case you need to tell it (at configure time) where to find
system headers.

Anyway, do you want your "c to c compiler" to be gcc clone?  Or
do you want to have your own appearance?  For example Tendra
project invested effort info providing "standard" interfaces
to various libraries.  Their standard header files were supposed
to be 100% standard compatible and they provided sanitized
headers for several libraries (IIRC that included X11).

-- 
                              Waldek Hebisch

[toc] | [prev] | [next] | [standalone]


#162800

FromThiago Adams <thiago.adams@gmail.com>
Date2021-09-21 12:01 -0700
Message-ID<b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>
In reply to#162796
On Tuesday, September 21, 2021 at 11:08:41 AM UTC-3, anti...@math.uni.wroc.pl wrote:
> Thiago Adams <thiago...@gmail.com> wrote: 
> > On Monday, September 20, 2021 at 9:54:29 PM UTC-3, Keith Thompson wrote: 
> > > sc...@slp53.sl.home (Scott Lurndal) writes: 
> > > > Thiago Adams <thiago...@gmail.com> writes: 
> > > >>On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote: 
> > > >>> On 20/09/2021 19:48, Thiago Adams wrote: 
> > > >>> > How to print gcc include path ? 
> > > >>> > 
> > > >>> > I tried with no success: 
> > > >>> > 
> > > >>> > const char* s = getenv("C_INCLUDE_PATH"); 
> > > >>> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
> > > >>> > printf("end test\n"); 
> > > >>> > 
> > > >>> I get the same on my Windows machine. The reason was because 
> > > >>> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
> > > >>> 
> > > >>> I think this is something that you define yourself, and it affects how 
> > > >>> gcc works. I think it just adds to the set of -I paths. 
> > > >> 
> > > >>On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt) 
> > > >>using: 
> > > >> 
> > > >>int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env)); 
> > > >> 
> > > >>I would like to do the same for gcc/clang on linux. 
> > > > 
> > > > Sorry, no can do. The search paths are built-in (/usr/include, 
> > > > /gcc-installation-path/include, et alia) 
> > > > and additional paths are specified via -I to the compiler 
> > > > by the programmer. 
> > > And gcc uses several environment variables to allow the user to 
> > > supplement the directories searched by gcc's built-in definitions and by 
> > > any -I options. See the gcc documentation for details. 
> > > 
> > > The $C_INCLUDE_PATH environment variable is not normally set. 
> > > > You can use 'gcc -H' to get a list of paths for each included 
> > > > file during compilation time. 
> > > https://stackoverflow.com/a/6666338/827263 
> > > 
> > > gcc -xc -E -v - </dev/null 
> > > 
> > 
> > I run the command this is the include part: 
> > 
> > /usr/lib/gcc/x86_64-linux-gnu/7/include 
> > /usr/local/include 
> > /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed 
> > /usr/include/x86_64-linux-gnu 
> > /usr/include 
> > 
> > Can I use this "hardcoded" and expect to work in any linux? 
> > /usr/include (stdlib.h is here for instance)
> In case you missed it: 7 in '/usr/lib/gcc/x86_64-linux-gnu/7/include' 
> is version number, so will be different for different gcc versions. 
> 'x86_64-linux-gnu' is platform name, on different platform like 
> ARM it will be different. 

How can I find out what is the default gcc? (sorry I am a windows
developer,  generally this kind of information is on Windows registry  
but I have no idea where to find this on Linux - This is a little of topic
but it also interesting for C developers to know where the compiler gets
its headers from)

 
> Also note that 'gcc' paths are gcc-internal. So they will point 
> to pleace where gcc lives. "Standard" gcc files are installed 
> in '/usr/lib', but there may be nostandard instalation say 
> in '/usr/local/lib' or in subdirectory of '/opt' (or inside 
> private user directory.
> > In windows we can have many versions of SDK, compilers..so to select 
> > one we can use the "Visual Studio Command prompt 2017" or 
> > "Visual Studio Command prompt 2019" etc. 
> > For gcc linux it seems that there is always one "default" pre-configured.
> Not "always": you need to install it. But you can instal non-default 
> compilers and they will peacefully co-exist. On my machine I have 
> few different versions of 'arm-none-eabi-gcc', each in it own directory 
> tree. When I invoke any of them using its full path each compiler 
> picks its own header files.
> > (My use case is to use the same include path of gcc inside my c to c compiler 
> > so the user does not need to inform -Ipath for each standard path)
> It is not clear what your "c to c compiler" is supposed to do. 
> Gcc and Linux paradigm is that there are few compiler supplied headers 
> and separate system headers. In Linux "system" headers used to be 
> in '/usr/include'. Multiarch system moved several headers to 
> '/usr/include/platform' where platform is something like 
> 'i386-linux-gnu'. However, gcc can work as cross-compiler and 
> in such case you need to tell it (at configure time) where to find 
> system headers. 
> 
> Anyway, do you want your "c to c compiler" to be gcc clone? Or 
> do you want to have your own appearance? For example Tendra 
> project invested effort info providing "standard" interfaces 
> to various libraries. Their standard header files were supposed 
> to be 100% standard compatible and they provided sanitized 
> headers for several libraries (IIRC that included X11). 

I want to use the same include path and parse the files in a similar
way not 100% clone.  For instance, the include file may have some
gcc specific ifdef my compiler will not use this part. Generally the
headers are friendly to accept other compilers. 





[toc] | [prev] | [next] | [standalone]


#162801

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2021-09-21 20:13 +0000
Message-ID<sideds$2cth0$1@news.xmission.com>
In reply to#162800
In article <b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>,
Thiago Adams  <thiago.adams@gmail.com> wrote:
...
>How can  I find  out what  is the default  gcc? (sorry  I am  a windows
>developer, generally  this kind of  information is on  Windows registry
>but I have  no idea where to find  this on Linux - This is  a little of
>topic  but it  also  interesting for  C developers  to  know where  the
>compiler gets its headers from)

Doesn't "gcc -v" tell you most of what you seek?

-- 
    The difference between communism and capitalism?
    In capitalism, man exploits man. In communism, it's the other way around.

	- Daniel Bell, The End of Ideology (1960) -

[toc] | [prev] | [next] | [standalone]


#162802

Fromscott@slp53.sl.home (Scott Lurndal)
Date2021-09-21 20:17 +0000
Message-ID<n5r2J.115515$rl3.104681@fx45.iad>
In reply to#162800
Thiago Adams <thiago.adams@gmail.com> writes:
>On Tuesday, September 21, 2021 at 11:08:41 AM UTC-3, anti...@math.uni.wroc.pl wrote:
>
>> In case you missed it: 7 in '/usr/lib/gcc/x86_64-linux-gnu/7/include' 
>> is version number, so will be different for different gcc versions. 
>> 'x86_64-linux-gnu' is platform name, on different platform like 
>> ARM it will be different. 
>
>How can I find out what is the default gcc? (sorry I am a windows
>developer,  generally this kind of information is on Windows registry  
>but I have no idea where to find this on Linux - This is a little of topic
>but it also interesting for C developers to know where the compiler gets
>its headers from)

There is no "default" GCC.  Every linux distribution is free to ship
whatever version of GCC they desire.   RHEL6/7, for example, still
ship GCC4, while the latest Ubuntu may have GCC10 or GCC11; and
a LTS release of Ubuntu  may have an earlier version.

[toc] | [prev] | [next] | [standalone]


#162805

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2021-09-21 20:35 +0000
Message-ID<sidfn7$2cth0$2@news.xmission.com>
In reply to#162802
In article <n5r2J.115515$rl3.104681@fx45.iad>,
Scott Lurndal <slp53@pacbell.net> wrote:
>Thiago Adams <thiago.adams@gmail.com> writes:
>>On Tuesday, September 21, 2021 at 11:08:41 AM UTC-3, anti...@math.uni.wroc.pl wrote:
>>
>>> In case you missed it: 7 in '/usr/lib/gcc/x86_64-linux-gnu/7/include' 
>>> is version number, so will be different for different gcc versions. 
>>> 'x86_64-linux-gnu' is platform name, on different platform like 
>>> ARM it will be different. 
>>
>>How can I find out what is the default gcc? (sorry I am a windows
>>developer,  generally this kind of information is on Windows registry  
>>but I have no idea where to find this on Linux - This is a little of topic
>>but it also interesting for C developers to know where the compiler gets
>>its headers from)
>
>There is no "default" GCC.  Every linux distribution is free to ship
>whatever version of GCC they desire.   RHEL6/7, for example, still
>ship GCC4, while the latest Ubuntu may have GCC10 or GCC11; and
>a LTS release of Ubuntu  may have an earlier version.

I assumed the question was: How can I find out what the default version ON
THIS MACHINE is.  "gcc -v" will tell you.

The point is that there may be many versions of gcc installed on a given
machine.  If your shell is more or less modern, the following keystroke
combo should tell you what all versions are installed:

$ gcc<Tab>

(where <Tab> represents pressing the tab key on your keyboard)

But "gcc" alone, should point to the "default" version.

-- 
BigBusiness types (aka, Republicans/Conservatives/Independents/Liberatarians/whatevers)
don't hate big government. They *love* big government as a means for them to get
rich, sucking off the public teat. What they don't like is *democracy* - you know,
like people actually having the right to vote and stuff like that.

[toc] | [prev] | [next] | [standalone]


#162808

Fromscott@slp53.sl.home (Scott Lurndal)
Date2021-09-21 21:30 +0000
Message-ID<7as2J.25867$j52.6015@fx18.iad>
In reply to#162805
gazelle@shell.xmission.com (Kenny McCormack) writes:
>In article <n5r2J.115515$rl3.104681@fx45.iad>,
>Scott Lurndal <slp53@pacbell.net> wrote:
>>Thiago Adams <thiago.adams@gmail.com> writes:
>>>On Tuesday, September 21, 2021 at 11:08:41 AM UTC-3, anti...@math.uni.wroc.pl wrote:
>>>
>>>> In case you missed it: 7 in '/usr/lib/gcc/x86_64-linux-gnu/7/include' 
>>>> is version number, so will be different for different gcc versions. 
>>>> 'x86_64-linux-gnu' is platform name, on different platform like 
>>>> ARM it will be different. 
>>>
>>>How can I find out what is the default gcc? (sorry I am a windows
>>>developer,  generally this kind of information is on Windows registry  
>>>but I have no idea where to find this on Linux - This is a little of topic
>>>but it also interesting for C developers to know where the compiler gets
>>>its headers from)
>>
>>There is no "default" GCC.  Every linux distribution is free to ship
>>whatever version of GCC they desire.   RHEL6/7, for example, still
>>ship GCC4, while the latest Ubuntu may have GCC10 or GCC11; and
>>a LTS release of Ubuntu  may have an earlier version.
>
>I assumed the question was: How can I find out what the default version ON
>THIS MACHINE is.  "gcc -v" will tell you.
>
>The point is that there may be many versions of gcc installed on a given
>machine.  If your shell is more or less modern, the following keystroke
>combo should tell you what all versions are installed:

Not necessarily.  On our development systems:

$ module avail -t 2>&1 | grep ^gcc
gcc/10.1
gcc/10.2
gcc/10.3
gcc/11.1
gcc/11.2
gcc/4.4   (default)
gcc/4.8.5
gcc/4.9
gcc/4.9.3
gcc/4.9.4
gcc/5.1
gcc/5.2
gcc/5.3
gcc/5.4
gcc/5.5
gcc/6.3
gcc/6.4
gcc/6.5
gcc/7.1
gcc/7.2
gcc/7.3
gcc/7.4
gcc/7.5
gcc/8.1
gcc/8.2
gcc/8.3
gcc/8.4
gcc/8.5
gcc/9.1
gcc/9.2
gcc/9.3
gcc/9.4
gcc/latest

$ gcc --version
gcc (GCC) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ module unload gcc/9.3
$ module load gcc/7.2
$ gcc --version
gcc (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ 

[toc] | [prev] | [next] | [standalone]


#162806

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-09-21 13:37 -0700
Message-ID<87czp1oebm.fsf@nosuchdomain.example.com>
In reply to#162802
scott@slp53.sl.home (Scott Lurndal) writes:
> Thiago Adams <thiago.adams@gmail.com> writes:
>>On Tuesday, September 21, 2021 at 11:08:41 AM UTC-3, anti...@math.uni.wroc.pl wrote:
>>
>>> In case you missed it: 7 in '/usr/lib/gcc/x86_64-linux-gnu/7/include' 
>>> is version number, so will be different for different gcc versions. 
>>> 'x86_64-linux-gnu' is platform name, on different platform like 
>>> ARM it will be different. 
>>
>>How can I find out what is the default gcc? (sorry I am a windows
>>developer,  generally this kind of information is on Windows registry  
>>but I have no idea where to find this on Linux - This is a little of topic
>>but it also interesting for C developers to know where the compiler gets
>>its headers from)
>
> There is no "default" GCC.  Every linux distribution is free to ship
> whatever version of GCC they desire.   RHEL6/7, for example, still
> ship GCC4, while the latest Ubuntu may have GCC10 or GCC11; and
> a LTS release of Ubuntu  may have an earlier version.

A user or administrator can install any version of gcc they like, in any
location they like.  The concept of "default" isn't really well defined.
The closest you can get is that the "default" for a given system is
probably /usr/bin/gcc, or at least the gcc that's in the user's default
$PATH (not all distributions necessarily distinguish between /usr/bin
and /bin).

If there's a /usr/local/bin/gcc that differs from /usr/bin/gcc, it's not
clear which of them is the "default".  Probably /usr/bin/gcc is the
default for the distribution and /usr/local/bin/gcc is the default for
that particular machine, or perhaps a collection of machines that are
administered together.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#162807

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-09-21 14:07 -0700
Message-ID<874kadocy1.fsf@nosuchdomain.example.com>
In reply to#162806
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> scott@slp53.sl.home (Scott Lurndal) writes:
>> Thiago Adams <thiago.adams@gmail.com> writes:
>>>On Tuesday, September 21, 2021 at 11:08:41 AM UTC-3, anti...@math.uni.wroc.pl wrote:
>>>
>>>> In case you missed it: 7 in '/usr/lib/gcc/x86_64-linux-gnu/7/include' 
>>>> is version number, so will be different for different gcc versions. 
>>>> 'x86_64-linux-gnu' is platform name, on different platform like 
>>>> ARM it will be different. 
>>>
>>>How can I find out what is the default gcc? (sorry I am a windows
>>>developer,  generally this kind of information is on Windows registry  
>>>but I have no idea where to find this on Linux - This is a little of topic
>>>but it also interesting for C developers to know where the compiler gets
>>>its headers from)
>>
>> There is no "default" GCC.  Every linux distribution is free to ship
>> whatever version of GCC they desire.   RHEL6/7, for example, still
>> ship GCC4, while the latest Ubuntu may have GCC10 or GCC11; and
>> a LTS release of Ubuntu  may have an earlier version.
>
> A user or administrator can install any version of gcc they like, in any
> location they like.  The concept of "default" isn't really well defined.
> The closest you can get is that the "default" for a given system is
> probably /usr/bin/gcc, or at least the gcc that's in the user's default
> $PATH (not all distributions necessarily distinguish between /usr/bin
> and /bin).
>
> If there's a /usr/local/bin/gcc that differs from /usr/bin/gcc, it's not
> clear which of them is the "default".  Probably /usr/bin/gcc is the
> default for the distribution and /usr/local/bin/gcc is the default for
> that particular machine, or perhaps a collection of machines that are
> administered together.

You also need to consider that the "cc" and "c99" commands may or may
not invoke gcc -- and if I recall correctly the "gcc" command on MacOS
typically invokes clang (the name "gcc" is used because a lot of build
scripts assume that gcc is present, and clang is usually close enough).

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#162809

Fromantispam@math.uni.wroc.pl
Date2021-09-21 23:05 +0000
Message-ID<sidogb$j06$1@z-news.wcss.wroc.pl>
In reply to#162800
Thiago Adams <thiago.adams@gmail.com> wrote:
> On Tuesday, September 21, 2021 at 11:08:41 AM UTC-3, anti...@math.uni.wroc.pl wrote:
> > Thiago Adams <thiago...@gmail.com> wrote: 
> > > On Monday, September 20, 2021 at 9:54:29 PM UTC-3, Keith Thompson wrote: 
> > > > sc...@slp53.sl.home (Scott Lurndal) writes: 
> > > > > Thiago Adams <thiago...@gmail.com> writes: 
> > > > >>On Monday, September 20, 2021 at 4:45:18 PM UTC-3, Bart wrote: 
> > > > >>> On 20/09/2021 19:48, Thiago Adams wrote: 
> > > > >>> > How to print gcc include path ? 
> > > > >>> > 
> > > > >>> > I tried with no success: 
> > > > >>> > 
> > > > >>> > const char* s = getenv("C_INCLUDE_PATH"); 
> > > > >>> > printf("C_INCLUDE_PATH :%s\n", (s != NULL) ? s : "getenv returned NULL"); 
> > > > >>> > printf("end test\n"); 
> > > > >>> > 
> > > > >>> I get the same on my Windows machine. The reason was because 
> > > > >>> C_INCLUDE_PATH is not defined as an OS environment variable, yet I run gcc. 
> > > > >>> 
> > > > >>> I think this is something that you define yourself, and it affects how 
> > > > >>> gcc works. I think it just adds to the set of -I paths. 
> > > > >> 
> > > > >>On windows I can get the include path used by Microsoft compiler (when running inside visual C prompt) 
> > > > >>using: 
> > > > >> 
> > > > >>int n = GetEnvironmentVariableA("INCLUDE", env, sizeof(env)); 
> > > > >> 
> > > > >>I would like to do the same for gcc/clang on linux. 
> > > > > 
> > > > > Sorry, no can do. The search paths are built-in (/usr/include, 
> > > > > /gcc-installation-path/include, et alia) 
> > > > > and additional paths are specified via -I to the compiler 
> > > > > by the programmer. 
> > > > And gcc uses several environment variables to allow the user to 
> > > > supplement the directories searched by gcc's built-in definitions and by 
> > > > any -I options. See the gcc documentation for details. 
> > > > 
> > > > The $C_INCLUDE_PATH environment variable is not normally set. 
> > > > > You can use 'gcc -H' to get a list of paths for each included 
> > > > > file during compilation time. 
> > > > https://stackoverflow.com/a/6666338/827263 
> > > > 
> > > > gcc -xc -E -v - </dev/null 
> > > > 
> > > 
> > > I run the command this is the include part: 
> > > 
> > > /usr/lib/gcc/x86_64-linux-gnu/7/include 
> > > /usr/local/include 
> > > /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed 
> > > /usr/include/x86_64-linux-gnu 
> > > /usr/include 
> > > 
> > > Can I use this "hardcoded" and expect to work in any linux? 
> > > /usr/include (stdlib.h is here for instance)
> > In case you missed it: 7 in '/usr/lib/gcc/x86_64-linux-gnu/7/include' 
> > is version number, so will be different for different gcc versions. 
> > 'x86_64-linux-gnu' is platform name, on different platform like 
> > ARM it will be different. 
> 
> How can I find out what is the default gcc? (sorry I am a windows
> developer,  generally this kind of information is on Windows registry  
> but I have no idea where to find this on Linux - This is a little of topic
> but it also interesting for C developers to know where the compiler gets
> its headers from)
 
On my laptop, when I type 'gcc' I get:

$ gcc --version
gcc (GCC) 3.4.6
....

When I type 'cc' I get:

$ cc --version
cc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

'cc' is gcc-6.3 intalled from distribution.  'gcc' is old version
which I installed in '/usr/local/bin' (there is also 'gcc' in
'/usr/bin', but '/usr/local/bin' is earlier in the path).

Shell is looking for commands in the patch, 'which' tells you
full path to command:

$ which gcc
/usr/local/bin/gcc

gcc has several options to print various info, from that you
can find out where it is installed.

> > Also note that 'gcc' paths are gcc-internal. So they will point 
> > to pleace where gcc lives. "Standard" gcc files are installed 
> > in '/usr/lib', but there may be nostandard instalation say 
> > in '/usr/local/lib' or in subdirectory of '/opt' (or inside 
> > private user directory.
> > > In windows we can have many versions of SDK, compilers..so to select 
> > > one we can use the "Visual Studio Command prompt 2017" or 
> > > "Visual Studio Command prompt 2019" etc. 
> > > For gcc linux it seems that there is always one "default" pre-configured.
> > Not "always": you need to install it. But you can instal non-default 
> > compilers and they will peacefully co-exist. On my machine I have 
> > few different versions of 'arm-none-eabi-gcc', each in it own directory 
> > tree. When I invoke any of them using its full path each compiler 
> > picks its own header files.
> > > (My use case is to use the same include path of gcc inside my c to c compiler 
> > > so the user does not need to inform -Ipath for each standard path)
> > It is not clear what your "c to c compiler" is supposed to do. 
> > Gcc and Linux paradigm is that there are few compiler supplied headers 
> > and separate system headers. In Linux "system" headers used to be 
> > in '/usr/include'. Multiarch system moved several headers to 
> > '/usr/include/platform' where platform is something like 
> > 'i386-linux-gnu'. However, gcc can work as cross-compiler and 
> > in such case you need to tell it (at configure time) where to find 
> > system headers. 
> > 
> > Anyway, do you want your "c to c compiler" to be gcc clone? Or 
> > do you want to have your own appearance? For example Tendra 
> > project invested effort info providing "standard" interfaces 
> > to various libraries. Their standard header files were supposed 
> > to be 100% standard compatible and they provided sanitized 
> > headers for several libraries (IIRC that included X11). 
> 
> I want to use the same include path and parse the files in a similar
> way not 100% clone.  For instance, the include file may have some
> gcc specific ifdef my compiler will not use this part. Generally the
> headers are friendly to accept other compilers.

Run gcc -E to preprocess input first.  In preprocessed output
you will will find path names of all files included during compilation.
Use the paths to find files for your compiler.  However,
I doubt if internal gcc headers are friendly to other compilers...

-- 
                              Waldek Hebisch

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web