Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. painted myself into a corner - again - need HELP

painted myself into a corner - again - need HELP

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiolinuxdebugginghelptutorial
4 Posts 3 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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

    L Mircea NeacsuM D 3 Replies Last reply
    0
    • L Lost User

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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 all qDebug calls to Debug (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

      1 Reply Last reply
      0
      • L Lost User

        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

        Mircea NeacsuM Offline
        Mircea NeacsuM Offline
        Mircea Neacsu
        wrote on last edited by
        #3

        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 string qDebug, 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 file new_source.cpp Good luck!

        Mircea

        1 Reply Last reply
        0
        • L Lost User

          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

          D Offline
          D Offline
          David ONeil
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups