Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #121494
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Now this is just annoying. |
| Date | 2025-02-03 15:33 -0800 |
| Organization | None to speak of |
| Message-ID | <874j1asiw9.fsf@nosuchdomain.example.com> (permalink) |
| References | <otOnP.1970339$oR74.850730@fx16.iad> <vnqj4e$1a4mb$1@raubtier-asyl.eternal-september.org> <gi7oP.166938$V9s2.113971@fx34.iad> |
scott@slp53.sl.home (Scott Lurndal) writes:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>Am 02.02.2025 um 19:05 schrieb Scott Lurndal:
>>> $ gcc --version
>>> gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3)
>>>
>>> $ g++ -O3 -o /tmp/a /tmp/a.cpp
>>> /tmp/a.cpp:4:1: warning: 'int main(int, const char**, const char**, const char**)' takes only zero or two arguments [-Wmain]
>>> 4 | main(int argc, const char **argv, const char **envp, const char **auxv)
>>> | ^~~~
>>>
>>> So much for backward compatibility and support for the original C++ operating
>>> environment (unix).
>>
>>Use getenv() - you don't need environment-variables you don't know.
>
> There are a number of use cases where your blanket statement is false.
It's both false (try implementing the printenv command with just
getenv()) and irrelevant. It's the 4th parameter to main, auxv, that
triggers the warning. And the environment vector can be accessed either
by defining
char **envp
as a parameter to main, or by declaring
extern char **environ;
(The envp parameter is a common extension, but it's not specified by
POSIX. environ is.)
And the information provided by the auxv parameter can be accessed via
the getauxval() function *if* your implementation provides it.
Apparently it's specific to ELF executables.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-02 18:05 +0000
Re: Now this is just annoying. red floyd <no.spam.here@its.invalid> - 2025-02-02 11:05 -0800
Re: Now this is just annoying. Muttley@DastardlyHQ.org - 2025-02-03 08:55 +0000
Re: Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-03 14:02 +0000
Re: Now this is just annoying. Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-02-03 15:34 -0800
Re: Now this is just annoying. Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-02-02 15:22 -0800
Re: Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-03 14:05 +0000
Re: Now this is just annoying. James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-02-02 18:43 -0500
Re: Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-03 14:06 +0000
Re: Now this is just annoying. Muttley@DastardlyHQ.org - 2025-02-03 14:10 +0000
Re: Now this is just annoying. Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-02-03 15:21 -0800
Re: Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-03 23:54 +0000
Re: Now this is just annoying. Bonita Montero <Bonita.Montero@gmail.com> - 2025-02-03 15:16 +0100
Re: Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-03 17:46 +0000
Re: Now this is just annoying. Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-02-03 15:33 -0800
Re: Now this is just annoying. Bonita Montero <Bonita.Montero@gmail.com> - 2025-02-04 07:20 +0100
Re: Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-04 14:30 +0000
Re: Now this is just annoying. Bonita Montero <Bonita.Montero@gmail.com> - 2025-02-04 17:25 +0100
Re: Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-04 20:20 +0000
Re: Now this is just annoying. Bonita Montero <Bonita.Montero@gmail.com> - 2025-02-05 08:53 +0100
Re: Now this is just annoying. scott@slp53.sl.home (Scott Lurndal) - 2025-02-05 15:09 +0000
Re: Now this is just annoying. Bonita Montero <Bonita.Montero@gmail.com> - 2025-02-05 16:11 +0100
Re: Now this is just annoying. "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2025-02-05 11:46 -0800
csiph-web