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. Cross Reference/Reporting Tool avaiable which does not resolve macros?

Cross Reference/Reporting Tool avaiable which does not resolve macros?

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiotutorialquestion
7 Posts 4 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
    Hans999
    wrote on last edited by
    #1

    maybe professionals here at codeproject have a hint for me. Please see following example:

    #include
    using namespace std;

    int c, d;

    #define Circumference c
    #define Diameter d

    int main ()
    {
    cout << "Please enter diameter: ";
    cin >> Diameter;

    Circumference = 3.14 * Diameter;

    cout << " Circumference is " << Circumference << endl;

    return 0;
    }

    My IDE (Understand) report possibilities always break down the #define to it's origin. So all reports state that function main() uses variables 'c' and 'd'. But what I like to have is the real used expression in the function source code. So report shoud show that main() uses 'Circumference' and 'Diameter' and not 'c' and 'd'. Is there any tool out there (for Windows 10 OS) which is able to do this ? Many thanks for any hint!

    'There are 10 types of people in this world, those who understand binary and those who dont.'

    L K D 3 Replies Last reply
    0
    • H Hans999

      maybe professionals here at codeproject have a hint for me. Please see following example:

      #include
      using namespace std;

      int c, d;

      #define Circumference c
      #define Diameter d

      int main ()
      {
      cout << "Please enter diameter: ";
      cin >> Diameter;

      Circumference = 3.14 * Diameter;

      cout << " Circumference is " << Circumference << endl;

      return 0;
      }

      My IDE (Understand) report possibilities always break down the #define to it's origin. So all reports state that function main() uses variables 'c' and 'd'. But what I like to have is the real used expression in the function source code. So report shoud show that main() uses 'Circumference' and 'Diameter' and not 'c' and 'd'. Is there any tool out there (for Windows 10 OS) which is able to do this ? Many thanks for any hint!

      'There are 10 types of people in this world, those who understand binary and those who dont.'

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

      I am not sure I understand what the problem is. I have just built and run your code successfully. But why are you doing it that way, what is wrong with: the following?

      #include using namespace std;

      int main ()
      {
      float Circumference;
      float Diameter;

      cout << "Please enter diameter: ";
      cin >> Diameter;
      
      Circumference = 3.14f \* Diameter;   // use f suffix to force float type
      
      cout << " Circumference is " << Circumference << endl;
      
      return 0;
      }
      
      1 Reply Last reply
      0
      • H Hans999

        maybe professionals here at codeproject have a hint for me. Please see following example:

        #include
        using namespace std;

        int c, d;

        #define Circumference c
        #define Diameter d

        int main ()
        {
        cout << "Please enter diameter: ";
        cin >> Diameter;

        Circumference = 3.14 * Diameter;

        cout << " Circumference is " << Circumference << endl;

        return 0;
        }

        My IDE (Understand) report possibilities always break down the #define to it's origin. So all reports state that function main() uses variables 'c' and 'd'. But what I like to have is the real used expression in the function source code. So report shoud show that main() uses 'Circumference' and 'Diameter' and not 'c' and 'd'. Is there any tool out there (for Windows 10 OS) which is able to do this ? Many thanks for any hint!

        'There are 10 types of people in this world, those who understand binary and those who dont.'

        K Offline
        K Offline
        k5054
        wrote on last edited by
        #3

        In C/C++ lines that start with # are preprocessor directives. What you need to understand about the preprocessor is what it basically does is text replacement. So what happens is that your C/C++ program text, lets call it program.cpp, gets passed through the preprocessor, and the output of that gets passed to the compiler proper. So lets say you have

        #define Circumference c
        #define Foo 10

        cout << Circumference << " " << Foo << end;

        When it gets to the compiler, it sees this:

        cout << c << " " << 10

        So the compiler proper never sees the #define statements. The fine print: The standards for C and C++ don't specify how the preprocessor is implemented, just how it should behave. Most compilers have chosen to implement the preprocessor as a separate executable, but it certainly doesn't have to be that way.

        Keep Calm and Carry On

        1 Reply Last reply
        0
        • H Hans999

          maybe professionals here at codeproject have a hint for me. Please see following example:

          #include
          using namespace std;

          int c, d;

          #define Circumference c
          #define Diameter d

          int main ()
          {
          cout << "Please enter diameter: ";
          cin >> Diameter;

          Circumference = 3.14 * Diameter;

          cout << " Circumference is " << Circumference << endl;

          return 0;
          }

          My IDE (Understand) report possibilities always break down the #define to it's origin. So all reports state that function main() uses variables 'c' and 'd'. But what I like to have is the real used expression in the function source code. So report shoud show that main() uses 'Circumference' and 'Diameter' and not 'c' and 'd'. Is there any tool out there (for Windows 10 OS) which is able to do this ? Many thanks for any hint!

          'There are 10 types of people in this world, those who understand binary and those who dont.'

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

          Why don't you do this instead:

          int main( void )
          {
          float Diameter;
          float Circumference;

          cout << "Please enter diameter: ";
          cin >> Diameter;

          Circumference = 3.14 * Diameter;

          cout << " Circumference is " << Circumference << endl;

          return 0;
          }

          Then it is more standard, and you also get what you want.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          L 1 Reply Last reply
          0
          • D David Crow

            Why don't you do this instead:

            int main( void )
            {
            float Diameter;
            float Circumference;

            cout << "Please enter diameter: ";
            cin >> Diameter;

            Circumference = 3.14 * Diameter;

            cout << " Circumference is " << Circumference << endl;

            return 0;
            }

            Then it is more standard, and you also get what you want.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

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

            Umm Re: Cross Reference/Reporting Tool avaiable which does not resolve macros? - C / C++ / MFC Discussion Boards[^].

            D 1 Reply Last reply
            0
            • L Lost User

              Umm Re: Cross Reference/Reporting Tool avaiable which does not resolve macros? - C / C++ / MFC Discussion Boards[^].

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

              Great minds think alike! Sorry about that. :-O I went from the OP to Reply, with no stops in between.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              L 1 Reply Last reply
              0
              • D David Crow

                Great minds think alike! Sorry about that. :-O I went from the OP to Reply, with no stops in between.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

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

                Done it myself occasionally.

                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