painted myself into a corner - again - need HELP
-
OK, yet another non code post.... I like to replace this qDebug() << text; with this #ifdef DEBUG qDebug() << text; #endif I have been told few times that XYZ is not IDE , but a library , hence its "editor" won't "search and replace with insert new line" so I end up with #ifdef DEBUG qDebug() << text; #endif and it won't compile. Any suggestions , besides taking on stamp collecting , on how to edit my entire , multi file, project ? Since I do not know how to make scripts, my only options are Linux commands or some other ,real and more capable , editor... Thanks Cheers
-
OK, yet another non code post.... I like to replace this qDebug() << text; with this #ifdef DEBUG qDebug() << text; #endif I have been told few times that XYZ is not IDE , but a library , hence its "editor" won't "search and replace with insert new line" so I end up with #ifdef DEBUG qDebug() << text; #endif and it won't compile. Any suggestions , besides taking on stamp collecting , on how to edit my entire , multi file, project ? Since I do not know how to make scripts, my only options are Linux commands or some other ,real and more capable , editor... Thanks Cheers
It's because
#ifdef
is a preprocessor statement and the the preprocessor requires the#ifdef
and the#endif
to be on separate lines. What you could do is use Find/Replace to convert allqDebug
calls toDebug
(or some other unique name), and then add something like the following at the top of you source, or in a common header:#ifdef DEBUG
#define Debug qDebug
#else
#define Debug
#endif -
OK, yet another non code post.... I like to replace this qDebug() << text; with this #ifdef DEBUG qDebug() << text; #endif I have been told few times that XYZ is not IDE , but a library , hence its "editor" won't "search and replace with insert new line" so I end up with #ifdef DEBUG qDebug() << text; #endif and it won't compile. Any suggestions , besides taking on stamp collecting , on how to edit my entire , multi file, project ? Since I do not know how to make scripts, my only options are Linux commands or some other ,real and more capable , editor... Thanks Cheers
Copy the following in a file called
script.awk
/qDebug/ {
print "#ifdef DEBUG"
print $0
print "#endif"
}
!/qDebug/Then a command like
awk -f script.awk source.cpp >new_source.cpp
would put a pair of #ifdef/#endif on any line containing qDebug. Obviously replace
source.cpp
with your source file. Translated into English, the script says: if line contains the stringqDebug
, print a line with #ifdef DEBUG, then print the line in question, then print a line with #endif. If line doesn't contain the string qDebug, just print it. The resulting output is put in filenew_source.cpp
Good luck!Mircea
-
OK, yet another non code post.... I like to replace this qDebug() << text; with this #ifdef DEBUG qDebug() << text; #endif I have been told few times that XYZ is not IDE , but a library , hence its "editor" won't "search and replace with insert new line" so I end up with #ifdef DEBUG qDebug() << text; #endif and it won't compile. Any suggestions , besides taking on stamp collecting , on how to edit my entire , multi file, project ? Since I do not know how to make scripts, my only options are Linux commands or some other ,real and more capable , editor... Thanks Cheers
If you can get Notepad++ working on Linux through Wine, as per [this page](https://itsfoss.com/notepad-plus-plus-linux/), you can record a script in it to do the job. Don't know how difficult it will be to do across multiple files, as far as opening them individually goes, but the script can be assigned a keyboard shortcut to make it easier. You can also use extended characters to search and replace every occurrence without having to trigger the macro for each instance in the file.
Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver