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 Question / getting detailed Class / Functioncall Information

Macro Question / getting detailed Class / Functioncall Information

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++questiondebugging
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.
  • S Offline
    S Offline
    Sendel
    wrote on last edited by
    #1

    I have a problem with Macros in Visual C++.:(( I want to write a more Detailed ErrorMessage Class, which gives me a part of sourcecode where the Error occurs. There are some predefined Macros which will help me to that: Current File: __FILE__ and Current Line: __LINE__ but I did not find a Macro for Current Call.:confused: So I want to make it my self.:omg:

    #define __CALL__ "void myFunction(int value);"
    void myFunction(int value)
    {
    printf("current Call is %s", __CALL__);
    }

    but problem is that I have to redo this procedure on every Function with additional undef:

    #ifdef __CALL__
    #undef __CALL__
    #endif
    #define __CALL__ "void myNextFunction(int value);"

    So, I want to reduce manual work by autmating the following code:

    #ifdef __CALL__
    #undef __CALL__
    #endif
    #define __CALL__ "void myFunction(int value);"

    so i want to do something like this (multiple Preprocessorcalls in one Macro:

    #define SETFUNCTION(x) #ifdef __CALL__ #undef __CALL__ #endif #define __CALL__ x

    :wtf: But it all seems not to work or it is a hard handwork to insert this long code before each function. X| So here are my Questions: 1. :confused:Is there any possibility to get easier more detailed Debug Information? (like current Function call) 2. :confused:Is there any way to make a Macro of Macros ? (like #define def(x) #ifndef x #define x #endif) Thank you :rose:, Sendel

    P 1 Reply Last reply
    0
    • S Sendel

      I have a problem with Macros in Visual C++.:(( I want to write a more Detailed ErrorMessage Class, which gives me a part of sourcecode where the Error occurs. There are some predefined Macros which will help me to that: Current File: __FILE__ and Current Line: __LINE__ but I did not find a Macro for Current Call.:confused: So I want to make it my self.:omg:

      #define __CALL__ "void myFunction(int value);"
      void myFunction(int value)
      {
      printf("current Call is %s", __CALL__);
      }

      but problem is that I have to redo this procedure on every Function with additional undef:

      #ifdef __CALL__
      #undef __CALL__
      #endif
      #define __CALL__ "void myNextFunction(int value);"

      So, I want to reduce manual work by autmating the following code:

      #ifdef __CALL__
      #undef __CALL__
      #endif
      #define __CALL__ "void myFunction(int value);"

      so i want to do something like this (multiple Preprocessorcalls in one Macro:

      #define SETFUNCTION(x) #ifdef __CALL__ #undef __CALL__ #endif #define __CALL__ x

      :wtf: But it all seems not to work or it is a hard handwork to insert this long code before each function. X| So here are my Questions: 1. :confused:Is there any possibility to get easier more detailed Debug Information? (like current Function call) 2. :confused:Is there any way to make a Macro of Macros ? (like #define def(x) #ifndef x #define x #endif) Thank you :rose:, Sendel

      P Offline
      P Offline
      Phil Hamer
      wrote on last edited by
      #2

      Putting the macro before the function definition will not work anyway, because the preprocessor will pass through the file first and keep #defining and #undefining SETFUNCTION, and finally SETFUNTION will only be the last function it processed. I thought of a macro like this: #define SETFUNCTION(x) TCHAR __CALL__[] = _T(#x) Put this as the first statement in all your functions, like this for example: void myFunction(int value) { SETFUNCTION(myFunction); ... } and now __CALL__ will simply be a string locally declared within each function. Hope that helps.

      P 1 Reply Last reply
      0
      • P Phil Hamer

        Putting the macro before the function definition will not work anyway, because the preprocessor will pass through the file first and keep #defining and #undefining SETFUNCTION, and finally SETFUNTION will only be the last function it processed. I thought of a macro like this: #define SETFUNCTION(x) TCHAR __CALL__[] = _T(#x) Put this as the first statement in all your functions, like this for example: void myFunction(int value) { SETFUNCTION(myFunction); ... } and now __CALL__ will simply be a string locally declared within each function. Hope that helps.

        P Offline
        P Offline
        Phil Hamer
        wrote on last edited by
        #3

        Actually, putting the macro before the function may work, I'm not sure. :) Either way, putting a statement at the start of each function seems like a lot of work to me, but I can't think of a better way.

        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