This forum has been archived. All content is frozen. Please use KDE Discuss instead.

nesting_ops test NDEBUG definition

Tags: None
(comma "," separated)
christianschluchter
Registered Member
Posts
2
Karma
0

nesting_ops test NDEBUG definition

Fri Jun 21, 2013 12:31 pm
Hi,
in nesting_ops.cpp test, there is this code:

#ifdef NDEBUG
const bool is_debug = false;
#else
const bool is_debug = true;
#endif

// Make really sure that we are in debug mode! We don't want any type of
// inlining for these tests to pass.
VERIFY(is_debug);

First of all, I'm just curious, why are you relying on debug mode? At least for now, it seams that the subsequent tests succeed as well if NDEBUG is defined.

My second question is, on Win EC, the test fails because NDEBUG is defined, which happens somewhere in Eigen/Core, which is included in main.h after NDEBUG is undefined. Does anyone know where this happens? I tried to narrow down, but could not find a single file in the Eigen src that defines NDEBUG and that is included (directly or via another file) in eigen/Core.

Thanks,
Christian
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
NDEBUG is never defined by Eigen itself. What if you add:
Code: Select all
#ifdef NDEBUG
#error NDEBUG defined before main.h
#endif
#include "main.h"
#ifdef NDEBUG
#error NDEBUG defined after main.h
#endif


at the beginning of the nested_ops.cpp file?

Maybe NDEBUG is defined by some system headers of win EC?

Actually, if EIGEN_NO_DEBUG or NDEBUG are defined before main.h, then we should undefined them. Then, if they are still defined afterwards, then we should abort compilation. And last, this VERIFY(is_debug); test should be replaced by a VERIFY_RAISE_ASSERT(eigen_assert(false));
christianschluchter
Registered Member
Posts
2
Karma
0
Thanks for your reply.
Your proposed code ends in NDEBUG defined after main.h. I actually did the whole exercise and found the NDEBUG definition in Windows CE's assert.h included by cassert included within Eigen/Core on line ~140. In assert.h is the following code:
Code: Select all
#if !defined(DEBUG) && !defined(NDEBUG)
#define NDEBUG 1
#endif // !defined(DEBUG) && !defined(NDEBUG)

DEBUG is not defined here, and therefore NDEBUG gets defined. To be honest, I don't have any idea why they check for DEBUG and not for _DEBUG. _DEBUG is actually defined at that point as it should be. I don't know where MS expects DEBUG to be defined, however.
I assume this is just another one of these CE specific bugs or inconsistencies.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
thanks:

https://bitbucket.org/eigen/eigen/commits/8054d6c46825/
Changeset: 8054d6c46825
User: ggael
Date: 2013-07-01 13:47:25
Summary: On windows CE, assert.h defines NDEBUG if DEBUG is not defined


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]