Re: Why is syntax error 'assert(false, "some text")' not discovered by Visual Studio?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2018-09-19 at 01:29 +0200, Regina Henschel wrote:
> Hi all,
> 
> I had the line
> assert(false, "Standard layer may not be deleted.");
> 
> But Visual Studio 2017 does not detect the syntax error. Is there 
> something wrong with my environment?

No there is nothing "wrong" with your environment.  It just means that
you are building with a release (or a non-debug) configuration.  In
C/C++, assert() is not a real function but a compiler macro, which
replaces what's inside the parentheses () with something with a no-op
if you are building a release build before the compiler even gets a
chance to parse it.

You can either re-build yours with a debug configuration, or if you
just want to enable assert in a specific file only without re-building
the whole thing, then you can just insert

#undef NDEBUG

at the beginning of the file to trigger the assert calls in that file
temporarily.

Here is a longer version of this explanation:

http://www.cplusplus.com/reference/cassert/assert/

Kohei

-- 
Kohei Yoshida, LibreOffice Calc volunteer hacker
_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux