Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

 *** System shutdown message from root *** System going down in 60 seconds


devel / comp.lang.c / Re: How to print gcc include path using C?

SubjectAuthor
* How to print gcc include path using C?Thiago Adams
`* Re: How to print gcc include path using C?Bart
 `* Re: How to print gcc include path using C?Thiago Adams
  `* Re: How to print gcc include path using C?Scott Lurndal
   `* Re: How to print gcc include path using C?Keith Thompson
    `* Re: How to print gcc include path using C?Thiago Adams
     +- Re: How to print gcc include path using C?Scott Lurndal
     +- Re: How to print gcc include path using C?Mark Bluemel
     `* Re: How to print gcc include path using C?antispam
      `* Re: How to print gcc include path using C?Thiago Adams
       +- Re: How to print gcc include path using C?Kenny McCormack
       +* Re: How to print gcc include path using C?Scott Lurndal
       |+* Re: How to print gcc include path using C?Kenny McCormack
       ||`- Re: How to print gcc include path using C?Scott Lurndal
       |`* Re: How to print gcc include path using C?Keith Thompson
       | `- Re: How to print gcc include path using C?Keith Thompson
       `- Re: How to print gcc include path using C?antispam

1
How to print gcc include path using C?

<495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18344&group=comp.lang.c#18344

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:202:: with SMTP id b2mr7997615qtx.158.1632163695835;
Mon, 20 Sep 2021 11:48:15 -0700 (PDT)
X-Received: by 2002:a0c:b44f:: with SMTP id e15mr27152597qvf.32.1632163695556;
Mon, 20 Sep 2021 11:48:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 20 Sep 2021 11:48:15 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.78; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.78
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
Subject: How to print gcc include path using C?
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Mon, 20 Sep 2021 18:48:15 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 7
 by: Thiago Adams - Mon, 20 Sep 2021 18:48 UTC

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");

Re: How to print gcc include path using C?

<siaoc8$1n4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18347&group=comp.lang.c#18347

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: How to print gcc include path using C?
Date: Mon, 20 Sep 2021 20:45:09 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <siaoc8$1n4$1@dont-email.me>
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 20 Sep 2021 19:45:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a178f37ebae033dd5b13c43726fc04f2";
logging-data="1764"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19t2xFAjPn5mYdmVgeasfBrrcFQzQqOQl8="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:CPM8EYhKOJVAmLKpYF3wbusTb8w=
In-Reply-To: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210920-4, 20/9/2021), Outbound message
 by: Bart - Mon, 20 Sep 2021 19:45 UTC

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.

Re: How to print gcc include path using C?

<d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18348&group=comp.lang.c#18348

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:7397:: with SMTP id t23mr5254820qtp.63.1632167716522;
Mon, 20 Sep 2021 12:55:16 -0700 (PDT)
X-Received: by 2002:a37:6108:: with SMTP id v8mr13332906qkb.199.1632167716145;
Mon, 20 Sep 2021 12:55:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 20 Sep 2021 12:55:15 -0700 (PDT)
In-Reply-To: <siaoc8$1n4$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.78; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.78
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <siaoc8$1n4$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
Subject: Re: How to print gcc include path using C?
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Mon, 20 Sep 2021 19:55:16 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 33
 by: Thiago Adams - Mon, 20 Sep 2021 19:55 UTC

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.

Re: How to print gcc include path using C?

<dp72J.43028$md6.29046@fx36.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18352&group=comp.lang.c#18352

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: How to print gcc include path using C?
Newsgroups: comp.lang.c
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <siaoc8$1n4$1@dont-email.me> <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
Lines: 31
Message-ID: <dp72J.43028$md6.29046@fx36.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 20 Sep 2021 21:53:13 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 20 Sep 2021 21:53:13 GMT
X-Received-Bytes: 1990
 by: Scott Lurndal - Mon, 20 Sep 2021 21:53 UTC

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.

Re: How to print gcc include path using C?

<87y27qoiip.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18359&group=comp.lang.c#18359

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: How to print gcc include path using C?
Date: Mon, 20 Sep 2021 17:54:22 -0700
Organization: None to speak of
Lines: 47
Message-ID: <87y27qoiip.fsf@nosuchdomain.example.com>
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
<siaoc8$1n4$1@dont-email.me>
<d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
<dp72J.43028$md6.29046@fx36.iad>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="bb72713767aed0d2b74b94bfa2480dba";
logging-data="25408"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SYc1mElPPgc89JG2NlTlH"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:EaI8SGlsuefMKTOxK9guXjJXwko=
sha1:I5RXIBRNHTtzbyK4RDAtDb/rWak=
 by: Keith Thompson - Tue, 21 Sep 2021 00:54 UTC

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 */

Re: How to print gcc include path using C?

<8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18364&group=comp.lang.c#18364

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:5142:: with SMTP id h2mr15048521qtn.92.1632226054267;
Tue, 21 Sep 2021 05:07:34 -0700 (PDT)
X-Received: by 2002:a0c:db0a:: with SMTP id d10mr30809291qvk.28.1632226054019;
Tue, 21 Sep 2021 05:07:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 21 Sep 2021 05:07:33 -0700 (PDT)
In-Reply-To: <87y27qoiip.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.78; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.78
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
<siaoc8$1n4$1@dont-email.me> <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
<dp72J.43028$md6.29046@fx36.iad> <87y27qoiip.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>
Subject: Re: How to print gcc include path using C?
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Tue, 21 Sep 2021 12:07:34 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 61
 by: Thiago Adams - Tue, 21 Sep 2021 12:07 UTC

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)

Re: How to print gcc include path using C?

<Qzl2J.13648$d82.6031@fx21.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18365&group=comp.lang.c#18365

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!news.uzoreto.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx21.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: How to print gcc include path using C?
Newsgroups: comp.lang.c
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <siaoc8$1n4$1@dont-email.me> <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com> <dp72J.43028$md6.29046@fx36.iad> <87y27qoiip.fsf@nosuchdomain.example.com> <8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>
Lines: 58
Message-ID: <Qzl2J.13648$d82.6031@fx21.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 21 Sep 2021 14:00:16 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 21 Sep 2021 14:00:16 GMT
X-Received-Bytes: 3351
 by: Scott Lurndal - Tue, 21 Sep 2021 14:00 UTC

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.

Re: How to print gcc include path using C?

<025fe88c-0667-4703-9d28-d8478e3c1cd5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18366&group=comp.lang.c#18366

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a0c:f38b:: with SMTP id i11mr31381849qvk.42.1632233224425;
Tue, 21 Sep 2021 07:07:04 -0700 (PDT)
X-Received: by 2002:a05:620a:3c4:: with SMTP id r4mr27687472qkm.480.1632233224134;
Tue, 21 Sep 2021 07:07:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 21 Sep 2021 07:07:03 -0700 (PDT)
In-Reply-To: <8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23c7:a280:3401:9004:3e89:10e4:846;
posting-account=3LA7mQoAAAByiBtHIUvpFq0_QEKnHGc9
NNTP-Posting-Host: 2a00:23c7:a280:3401:9004:3e89:10e4:846
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
<siaoc8$1n4$1@dont-email.me> <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
<dp72J.43028$md6.29046@fx36.iad> <87y27qoiip.fsf@nosuchdomain.example.com> <8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <025fe88c-0667-4703-9d28-d8478e3c1cd5n@googlegroups.com>
Subject: Re: How to print gcc include path using C?
From: mark.blu...@gmail.com (Mark Bluemel)
Injection-Date: Tue, 21 Sep 2021 14:07:04 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 64
 by: Mark Bluemel - Tue, 21 Sep 2021 14:07 UTC

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.

Re: How to print gcc include path using C?

<sicp12$4ia$1@z-news.wcss.wroc.pl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18367&group=comp.lang.c#18367

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.c
Subject: Re: How to print gcc include path using C?
Date: Tue, 21 Sep 2021 14:08:34 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 97
Message-ID: <sicp12$4ia$1@z-news.wcss.wroc.pl>
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <siaoc8$1n4$1@dont-email.me> <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com> <dp72J.43028$md6.29046@fx36.iad> <87y27qoiip.fsf@nosuchdomain.example.com> <8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1632233314 4682 156.17.86.1 (21 Sep 2021 14:08:34 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Tue, 21 Sep 2021 14:08:34 +0000 (UTC)
Cancel-Lock: sha1:SypYu0ViIWuHv4f7cKGaTRWwGiQ=
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-10-amd64 (x86_64))
X-Received-Bytes: 5536
 by: antis...@math.uni.wroc.pl - Tue, 21 Sep 2021 14:08 UTC

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

Re: How to print gcc include path using C?

<b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18371&group=comp.lang.c#18371

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:40e:: with SMTP id 14mr18608027qke.197.1632250872492;
Tue, 21 Sep 2021 12:01:12 -0700 (PDT)
X-Received: by 2002:a05:620a:2a07:: with SMTP id o7mr31503850qkp.213.1632250872197;
Tue, 21 Sep 2021 12:01:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 21 Sep 2021 12:01:12 -0700 (PDT)
In-Reply-To: <sicp12$4ia$1@z-news.wcss.wroc.pl>
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.78; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.78
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
<siaoc8$1n4$1@dont-email.me> <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
<dp72J.43028$md6.29046@fx36.iad> <87y27qoiip.fsf@nosuchdomain.example.com>
<8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com> <sicp12$4ia$1@z-news.wcss.wroc.pl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>
Subject: Re: How to print gcc include path using C?
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Tue, 21 Sep 2021 19:01:12 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 107
 by: Thiago Adams - Tue, 21 Sep 2021 19:01 UTC

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.

Re: How to print gcc include path using C?

<sideds$2cth0$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18372&group=comp.lang.c#18372

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: Re: How to print gcc include path using C?
Date: Tue, 21 Sep 2021 20:13:48 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sideds$2cth0$1@news.xmission.com>
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com> <sicp12$4ia$1@z-news.wcss.wroc.pl> <b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>
Injection-Date: Tue, 21 Sep 2021 20:13:48 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2520608"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 21 Sep 2021 20:13 UTC

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) -

Re: How to print gcc include path using C?

<n5r2J.115515$rl3.104681@fx45.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18373&group=comp.lang.c#18373

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: How to print gcc include path using C?
Newsgroups: comp.lang.c
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <siaoc8$1n4$1@dont-email.me> <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com> <dp72J.43028$md6.29046@fx36.iad> <87y27qoiip.fsf@nosuchdomain.example.com> <8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com> <sicp12$4ia$1@z-news.wcss.wroc.pl> <b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>
Lines: 18
Message-ID: <n5r2J.115515$rl3.104681@fx45.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 21 Sep 2021 20:17:23 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 21 Sep 2021 20:17:23 GMT
X-Received-Bytes: 1956
 by: Scott Lurndal - Tue, 21 Sep 2021 20:17 UTC

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.

Re: How to print gcc include path using C?

<sidfn7$2cth0$2@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18374&group=comp.lang.c#18374

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: Re: How to print gcc include path using C?
Date: Tue, 21 Sep 2021 20:35:51 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sidfn7$2cth0$2@news.xmission.com>
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <sicp12$4ia$1@z-news.wcss.wroc.pl> <b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com> <n5r2J.115515$rl3.104681@fx45.iad>
Injection-Date: Tue, 21 Sep 2021 20:35:51 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2520608"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 21 Sep 2021 20:35 UTC

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.

Re: How to print gcc include path using C?

<87czp1oebm.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18375&group=comp.lang.c#18375

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: How to print gcc include path using C?
Date: Tue, 21 Sep 2021 13:37:17 -0700
Organization: None to speak of
Lines: 37
Message-ID: <87czp1oebm.fsf@nosuchdomain.example.com>
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
<siaoc8$1n4$1@dont-email.me>
<d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
<dp72J.43028$md6.29046@fx36.iad>
<87y27qoiip.fsf@nosuchdomain.example.com>
<8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>
<sicp12$4ia$1@z-news.wcss.wroc.pl>
<b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>
<n5r2J.115515$rl3.104681@fx45.iad>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="bb72713767aed0d2b74b94bfa2480dba";
logging-data="17479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182WikIesrf72wW/qKjMPsZ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:Purk/k0iUXVyCe3taOGpPp4HpNc=
sha1:mCTVJyFwa/EQBRA/8+7IeQbwtYM=
 by: Keith Thompson - Tue, 21 Sep 2021 20:37 UTC

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 */

Re: How to print gcc include path using C?

<874kadocy1.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18376&group=comp.lang.c#18376

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: How to print gcc include path using C?
Date: Tue, 21 Sep 2021 14:07:02 -0700
Organization: None to speak of
Lines: 43
Message-ID: <874kadocy1.fsf@nosuchdomain.example.com>
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com>
<siaoc8$1n4$1@dont-email.me>
<d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com>
<dp72J.43028$md6.29046@fx36.iad>
<87y27qoiip.fsf@nosuchdomain.example.com>
<8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com>
<sicp12$4ia$1@z-news.wcss.wroc.pl>
<b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>
<n5r2J.115515$rl3.104681@fx45.iad>
<87czp1oebm.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="bb72713767aed0d2b74b94bfa2480dba";
logging-data="17479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+g7c9iWe63hOdmSmJWtj0t"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:kSp0FBMqQvgo3DKttslqXCXwMUs=
sha1:Jk2FSUZL3J1XfF1S1dGCW/1fk74=
 by: Keith Thompson - Tue, 21 Sep 2021 21:07 UTC

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 */

Re: How to print gcc include path using C?

<7as2J.25867$j52.6015@fx18.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18377&group=comp.lang.c#18377

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx18.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: How to print gcc include path using C?
Newsgroups: comp.lang.c
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <sicp12$4ia$1@z-news.wcss.wroc.pl> <b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com> <n5r2J.115515$rl3.104681@fx45.iad> <sidfn7$2cth0$2@news.xmission.com>
Lines: 81
Message-ID: <7as2J.25867$j52.6015@fx18.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 21 Sep 2021 21:30:43 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 21 Sep 2021 21:30:43 GMT
X-Received-Bytes: 3264
 by: Scott Lurndal - Tue, 21 Sep 2021 21:30 UTC

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.

$

Re: How to print gcc include path using C?

<sidogb$j06$1@z-news.wcss.wroc.pl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18378&group=comp.lang.c#18378

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.c
Subject: Re: How to print gcc include path using C?
Date: Tue, 21 Sep 2021 23:05:47 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 134
Message-ID: <sidogb$j06$1@z-news.wcss.wroc.pl>
References: <495715dd-5751-4e4c-aca9-5e21eeeea523n@googlegroups.com> <siaoc8$1n4$1@dont-email.me> <d496b340-5ae0-4482-886a-3a8dc8fea3f8n@googlegroups.com> <dp72J.43028$md6.29046@fx36.iad> <87y27qoiip.fsf@nosuchdomain.example.com> <8c9ee357-2795-43ed-839c-ae7341912d6an@googlegroups.com> <sicp12$4ia$1@z-news.wcss.wroc.pl> <b83285a3-66df-438a-a949-f9c3c8acafdfn@googlegroups.com>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1632265547 19462 156.17.86.1 (21 Sep 2021 23:05:47 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Tue, 21 Sep 2021 23:05:47 +0000 (UTC)
Cancel-Lock: sha1:tFK4xB50dk1e5h5aEyYJQ2rGCZ4=
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-10-amd64 (x86_64))
 by: antis...@math.uni.wroc.pl - Tue, 21 Sep 2021 23:05 UTC

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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor