There seems to be know standard way of issuing a warning with the expectation that compilation will continue.We have #warning but it isn't standard.We have static_assert but it always stops compilation.
#else#warning "Default implementation might not be suitable for your platform, please check”
There is nothing stopping you from writing a static_warning similar to how boost wrote BOOST_STATIC_ASSERT. And then, once you have something working, propose it to boost and/or the committee.
The big question would be what level or warning - or do I get to decide?
Considering that warnings, of any kind, are outside the standard, it might be hard to get this beyond boost-level.
Tony
On 2014-08-29 13:56, Tony V E wrote:
<snip>
> There is nothing stopping you from writing a static_warning similar to
> how boost wrote BOOST_STATIC_ASSERT.
Or use the existing one:
On Wednesday 03 September 2014 22:56:22 gmis...@gmail.com wrote:
> One use case is that if you write a load of code and chunks aren't
> implemented yet, say for a particular platform, I.e. code is left with a
> big hole.
> #if _WIN32
> win32();
> #elif _APPLE_
> apple();
> #else
> HeyYouNeedToWriteThis(); /// #warning you're our only hope.
> #endif
This is not a good example of #warning. This is an example of #error.
I'm happy to write up an initial proposal based on this starting proposition.I don't intend to present such a paper in person though so I would need someone interested in supporting me in that.Any further support beyond that, in this endeavour would be great too.
On Thursday, September 4, 2014 3:49:29 PM UTC+8, gmis...@gmail.com wrote:I'm happy to write up an initial proposal based on this starting proposition.I don't intend to present such a paper in person though so I would need someone interested in supporting me in that.Any further support beyond that, in this endeavour would be great too.
I'd get behind a static_log.
The term "warning" implies some level of danger, whereas the only acceptable level of danger is nil.
But I'll go into the options around this when I post something in the next few days and everyone can lay into that then maybe.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
There is nothing stopping you from writing a static_warning similar to how boost wrote BOOST_STATIC_ASSERT. And then, once you have something working, propose it to boost and/or the committee.
Hello.
I’m quite an outsider in this list but I would like to express my opinion.
There’s something quite misleading I see in your summary of the intended proposal,
namely the association between #warning and static_assert.
You list the non-standard alternatives of #warning, #pragma message and so on, and then
you list BOOST_STATIC_WARNING.
You say BOOST_STATIC_WARNING is about “#warning but with an interface more similar to static_assert()”,
but it’s not totally correct. It’s not a matter of interface, it’s a matter of capabilities of the feature.
#warning is a preprocessor directive, perfectly similar to #error, and talks about messages generated in
the preprocessing phase.
static_assert(), on the other hand, gets evaluated a lot later in the chain, and can be used to detect
errors during the compilation. It’s an entirely different beast.
People use the non-standard #warning directive to warn about unimplemented features in headers
on unsupported platforms or missing macro definitions or things like that, while an hypothetical
static_message() similar to static_assert() would enable the code to talk its users about template
parameters, types etc…
I know everybody on this list knows the difference between this concepts and I don’t feel like I
need to explain them better.
My point is that it’s not at all clear what this proposal is about. A standard #warning preprocessor
directive, or a compile-time static_message(), similar in principle to static_assert()?
My personal feeling is that standardizing the common practice of #warning could be very reasonable,
given the broad support of this extension. static_message() could be useful too, but I think it should
be proposed together with a revision of the limits of static_assert() (the possibility to compute
at compile time the message instead of being limited to a literal, etc…)
Bye,
Nicola
Of course static_assert is more general.
#ifndef SOMEPLATFORMMACRO
#error This platform is not supported
#endif
You could change it to:
static_assert(SOMEPLATFORMMACRO, “You get the idea”);
But you don’t get the same behavior. #error stops the preprocessing
phase, so the compiler doesn’t bother with anything that could be
wrong in the code (and if you’re quitting because your platform is
unsupported, a lot of things are broken down there). If you replace
the #error with the static_assert you get the same error message but
the compiler have to parse the code, so you get flooded with a whole
bunch of other errors that confuse the user and hide the real problem.
This is not the case with #warning and static_message(), since they would
not stop the compilation either way, but since you asked about static_assert
I’ve answered.
I completely agree that a static_message() facility would be more useful in general than #warning. The point is that
they’re different things and should be dealt with in different discussions. If you want to extend the language by
adding the capability of printing a message during compilation to warn the user about dubious things at compile time,
to complement static_assert(), than propose static_message().
If you want to propose the standardization of a common and widespread extension, thus making compliant a ton
of existing code out there, than propose #warning.
I think both have merits and I would be happy the see them in the next standard. But I would not be completely satisfied by
the inclusion of static_message() but not of #warning, only on the basis that the latter is reducible to the former, because
I would like to see the ton of code already using #warning becoming conforming code.
Bye,
Nicola
Yes, that's my goals:1. make code that is using #warning Standard somehow2. make code that is using BOOST_STATIC_WARNING Standard somehow.I don't care if that happens directly or indirectly. By that I mean, I don't care if they become Standard "as is" or have a simple mechanical upgrade paths to some other feature that is Standard.
I'm happy that be one proposal or into two if that's the consensus which I'm hearing is your preference.It seems you voting on:1. Make #warning Standard so some errors can get reported on in the pre-processing phase where that is wanted.2. Introduce static_warning(expr,msg) too so errors can get reported after the pre-processing phase and in a more flexible way.That achieves both my goals.I'm less sure what you may be saying about static_message.My position on it is that is, conceptually a static_warning and a static_message feature are two very similar but different things.At the simplest level, I anticipate the compiler processing static_warning and desiring to stick 'Warning' in the message for you not that it has to, but that it could. but you also might want to report a version number or some debug info in your code which isn't a warning really, in that instance a static_message type feature is what you'd want and there the compiler would be encouraged to NOT put 'Warning' in the message.static_warning is the essential and useful feature. But I see value in both.I'm keen to try to resolve the terminology and use cases to something that is clear in everyone's minds.At a more complex level, static_warning can be effected by other options like compile with no warnings. Where a static_message feature would be enabled/disabled by other options. This further shows the distinction.In summary I'm hearing/seeing:Make #warning standard roughly "as is". Introduce static_message(expr,msg) to cover BOOST_STATIC_WARNING(expr).Tbd. on value of static_messagePut #warning in one proposal, static_warning in another with perhaps static_message as a sub part of that second proposal.How do you feel about that?
Thanks to you,Thanks
Option #5 - Extend static_assert to support warnings and possibly messages too.We have: static_assert(expr) and static_assert(expr, msg).
We could add: static_assert(expr, msg, kind = assert_kind::error);
e.g. enum class assert_kind { error, warning /*, info, note*/ };