Jump to content

Talk:assert.h

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia


Removed statements

[edit]

@Spitzak: Several points I noted about your recent removals:

  • The note was removed, which I find an odd change. abort() is defined in stdlib.h

- you can add that back in without undoing the important changes

  • The bit about __FILE__ and __LINE__ was removed. Again, odd, considering that those two preprocessor macros are used by assert(). I looked over the statement I added again, just in case I had said that it returns it or something along those lines, but what's written to stderr is, in fact, those two preprocessor macros.

- again you can add that in without undoing the important changes, though I really don't think it is an important detail. Also I think the example which I re-added does a much better job.

  • The example was changed and the result of compiling the example is provided. I don't see the use in providing what the program would compile to simply because there are multiple different compilers and operating systems, and I prefer to keep pages free of code blocks (especially console outputs).

- There is very little difference in the result on various compilers. ALL of them will do the assert and abort at the same time. IMHO this example does much much more in explaining things than all the text you seem to want to add. Also I HAD to undo a lot of mistakes, in particular about "compiling" (it will compile whether or not the assert will throw), and to change the program to one that will actually trigger an assert.

  • Several sentences, such as "Notice that this does not execute the expression, relying on side-effects of the assert expression is a common mistake" and "Originally this was done with template hacks (which are impossible in C), but all modern compilers provide direct support for this" lack references and, in the case of the former, read more as guides than an actual page. I should have mentioned that NDEBUG negates assert.h as the example in there was ambiguous to a beginner, but I disagree with how you wrote this sentence. To fit with the encyclopedic theme, perhaps something like, "NDEBUG results in the assert macro to not be executed."

- The fact that the expression is not evaluated when debugging is disabled is probably infinitely far more important than which compiler macro is used or what header file abort() is in, so I am confused why you think that should not be there. The template stuff is an attempt to explain why static_assert showed up in C++ before it was in C.

  • A huge chunk of the part about static_assert was removed. I'll admit that I omitted the compile-time portion (for C++) on accident, I had intended to include it but completely forgot to. I don't see why reverting an entire edit over that is justified. I looked over some of the changes and everything makes sense. static_assert does require a constant expression (contextually) that can be converted into a Boolean, such as a comparison, and a string literal (until C++17). Working with these articles is rather difficult because all changes to how a declaration works need to be expressed, such as C++17 no longer requiring a string literal as the message. Still, I mentioned that (albeit after the fact, as not everyone uses C++17). I also don't see why the part about <cassert> and assert.h had to be moved and removed respectively. Personally, I use the former, but both are fair to mention as C++ allows for the latter for interoperability (and I'm not willing to have a debate over whether it should be included, it's important to the article's topic).

- Here was by far the biggest mistakes. You left tons on stuff about assert mixed in here (the C++ header file was one of those), duplicated stuff, and mangled the text so the fact that it is compile-time seemed to be only for C99 and not C++. Please do not change this unless you clearly keep on subject and only talk about static_assert!

  • Your changes turned at least one paragraph into a sentence, and there are several other short paragraphs.

I understand having different mindsets about how to work an article, but everything I've stated is sourced, unless I'm overlooking something here. Perhaps you mean mistakes as in prose mistakes, rather than factual mistakes? elijahpepe@wikipedia (he/him) 03:55, 18 March 2023 (UTC)[reply]

Yes because the big paragraph duplicated information, contained completely erroneous statements, and merged multiple subjects (don't talk about assert in a section titled static_assert, for one thing!).Spitzak (talk) 15:52, 18 March 2023 (UTC)[reply]
I can't seem to find any such duplicated information that you're talking about. elijahpepe@wikipedia (he/him) 16:57, 18 March 2023 (UTC)[reply]

In C99, the assert macro explicitly allows any scalar type.

[edit]

Can anybody explain what this means? I am suspicious this is a meaningless statement from the Linux man page that people keep copying, and that all the "new types" are in C99 anyway and therefore the C89 assert was capable of doing every type that could work. Is there an example of something that did not work in C89 assert statement that should? What are these types that are "scalar" but cannot be cast to int? Spitzak (talk) 19:37, 19 March 2023 (UTC)[reply]

There's no difference, but the distinction should still be noted as part of changes made to the macro. elijahpepe@wikipedia (he/him) 21:52, 19 March 2023 (UTC)[reply]