C++ Logo

std-proposals

Advanced search

Re: [std-proposals] A draft for a std::arguments proposal

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 15 Oct 2024 23:24:56 -0700
On Tuesday 15 October 2024 23:08:08 GMT-7 Ville Voutilainen wrote:
> And that's fine. Programs using Qt (perhaps indirectly) that want to
> get the full cmdline args can do so. Programs that want to get the
> non-framework arguments can do so. Qt doesn't need to impose the
> framework-argument-filtering on all code. So,
> we do *not* _need_ to modify std::arguments() in Qt.

Since the QCoreApplication and derived classes' only public constructor takes
argc and argv, you have to actively lie to Qt to achieve that. I've seen
people do that:

  int argc = 1;
  char *argv[] = { const_cast<char *>("myapp") };
  QCoreApplication app(argc, argv);

But see my reply to Tiago just now. Doing the above to hide the arguments from
filtering is probably counter-productive to your application, because it will
therefore not handle some command-line options that users or the system may
expect it to.

If you do pass the regular argc and argv, then there will be a discrepancy
between it and std::arguments().

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2024-10-16 06:25:00