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. Predifined macro (__FUNCTION__)

Predifined macro (__FUNCTION__)

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 3 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.
  • H Offline
    H Offline
    hint_54
    wrote on last edited by
    #1

    I need to pass the macro __FUNCTION__ to a constructor (it's for error handling) but that macro will not work on any compiler. What I want to know is if there is a way of knowing if the macro is avaiable with pre-processor directives. Something like:

    #ifdef SOMETHING
    MyConstructor( int );
    #else
    MyConstructor( void );
    #endif

    Where SOMETHING is only defined if __FUNCTION__ is avaiable. Is this possible? If not, is there any other way? Thanks in advance hint_54

    D M 2 Replies Last reply
    0
    • H hint_54

      I need to pass the macro __FUNCTION__ to a constructor (it's for error handling) but that macro will not work on any compiler. What I want to know is if there is a way of knowing if the macro is avaiable with pre-processor directives. Something like:

      #ifdef SOMETHING
      MyConstructor( int );
      #else
      MyConstructor( void );
      #endif

      Where SOMETHING is only defined if __FUNCTION__ is avaiable. Is this possible? If not, is there any other way? Thanks in advance hint_54

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      hint_54 wrote:

      ...if __FUNCTION__ is avaiable.

      Can't you just use:

      #ifdef __FUNCTION__
      ...
      #endif


      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

      "There is no death, only a change of worlds." - Native American Proverb

      H 1 Reply Last reply
      0
      • D David Crow

        hint_54 wrote:

        ...if __FUNCTION__ is avaiable.

        Can't you just use:

        #ifdef __FUNCTION__
        ...
        #endif


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        H Offline
        H Offline
        hint_54
        wrote on last edited by
        #3

        I dont know. I dont have the means to test it. My compiler (VS6) does not support the __FUNCTION__ macro. You think it will work? regards hint_54

        1 Reply Last reply
        0
        • H hint_54

          I need to pass the macro __FUNCTION__ to a constructor (it's for error handling) but that macro will not work on any compiler. What I want to know is if there is a way of knowing if the macro is avaiable with pre-processor directives. Something like:

          #ifdef SOMETHING
          MyConstructor( int );
          #else
          MyConstructor( void );
          #endif

          Where SOMETHING is only defined if __FUNCTION__ is avaiable. Is this possible? If not, is there any other way? Thanks in advance hint_54

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          __FUNCTION__ was added in VC7, so you can test for the existence of __FUNCTION__ by checking the value of _MSC_VER (the compiler version).

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

          H 1 Reply Last reply
          0
          • M Michael Dunn

            __FUNCTION__ was added in VC7, so you can test for the existence of __FUNCTION__ by checking the value of _MSC_VER (the compiler version).

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

            H Offline
            H Offline
            hint_54
            wrote on last edited by
            #5

            What about the compilers that are not from microsoft? regards hint_54

            M 1 Reply Last reply
            0
            • H hint_54

              What about the compilers that are not from microsoft? regards hint_54

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #6

              I really have little knowledge of non-MS compilers these days. RTFM ;)

              --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

              H 1 Reply Last reply
              0
              • M Michael Dunn

                I really have little knowledge of non-MS compilers these days. RTFM ;)

                --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

                H Offline
                H Offline
                hint_54
                wrote on last edited by
                #7

                true ;P hint_54

                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