I'm working on minor changes to a multi-platform C++ project with a 400-line Linux makefile that someone else created years ago.
Two lines in the makefile use -dndebug
(lower-case) as a command-line argument to g++.
I think the intention was to define the ndebug
symbol, but does the argument even do anything when it's lower-case?
I have minimal knowledge of g++ and make but, going by the page linked below, I think the argument needs to be upper-case to work.
http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html
Yes, it should be upper case like this -DNDEBUG
.
-D
is the GCC option to define a macro. NDEBUG
is the macro to be defined to turn off asserts as mandated by the C standard.
I have minimal knowledge of g++ and make but, going by the page linked below, I think the argument needs to be upper-case to work.
As for -dndebug
, since macros are case-sensitive, I think it will not have any effect i.e. it should get ignored, unless there is some code you have that references it.
It's fairly easy to test:
$ cat test.cpp
#include <iostream>
int main()
{
#ifdef TEST_DEFINE
std::cout << "defined" << std::endl;
#endif
return 0;
}
$ g++ -o 1 -DTEST_DEFINE test.cpp
$ ./1
defined
$ g++ -o 2 -dTEST_DEFINE test.cpp
cc1plus: warning: unrecognized gcc debugging option: T [enabled by default]
cc1plus: warning: unrecognized gcc debugging option: E [enabled by default]
cc1plus: warning: unrecognized gcc debugging option: S [enabled by default]
cc1plus: warning: unrecognized gcc debugging option: T [enabled by default]
cc1plus: warning: unrecognized gcc debugging option: _ [enabled by default]
cc1plus: warning: unrecognized gcc debugging option: E [enabled by default]
cc1plus: warning: unrecognized gcc debugging option: F [enabled by default]
cc1plus: warning: unrecognized gcc debugging option: E [enabled by default]
$ ./2
$
So as you can see the -d
option actually causes compiler warnings so it looks like -D
is what was intended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With