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. MACRO which give me the line number of a cpp file?!?

MACRO which give me the line number of a cpp file?!?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialhelpquestion
3 Posts 2 Posters 0 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.
  • R Offline
    R Offline
    Raphael Kindt
    wrote on last edited by
    #1

    Hi world, When I throw an exception I'll want to use a function (or a MACRO) which give me the line number where the throw was detected... for example:

    throw SLD_Exception(error_code, "error message", THE_LINE_NUMBER);

    ...if this line is the 86th, then THE_LINE_NUMBER must return 86... Is this possible??? How to do that??? (I don't use MFC... and don't want to use it...) Thanks in advance! Hello World!!! :) from Raphaël

    M 1 Reply Last reply
    0
    • R Raphael Kindt

      Hi world, When I throw an exception I'll want to use a function (or a MACRO) which give me the line number where the throw was detected... for example:

      throw SLD_Exception(error_code, "error message", THE_LINE_NUMBER);

      ...if this line is the 86th, then THE_LINE_NUMBER must return 86... Is this possible??? How to do that??? (I don't use MFC... and don't want to use it...) Thanks in advance! Hello World!!! :) from Raphaël

      M Offline
      M Offline
      Martyn Pearson
      wrote on last edited by
      #2

      Try __LINE__ for the source code line. __FILE__ might also be of interest - this is the source filename. Hope this helps!

      R 1 Reply Last reply
      0
      • M Martyn Pearson

        Try __LINE__ for the source code line. __FILE__ might also be of interest - this is the source filename. Hope this helps!

        R Offline
        R Offline
        Raphael Kindt
        wrote on last edited by
        #3

        Thank you... that work fine... Hello World!!! :) from Raphaël

        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