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


Groups > comp.lang.c > #162788

Re: How to print gcc include path using C?

Path csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <Keith.S.Thompson+u@gmail.com>
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> (permalink)
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=
Xref csiph.com comp.lang.c:162788

Show key headers only | View raw


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

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web