Cross Reference/Reporting Tool avaiable which does not resolve macros?
-
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 dint 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.'
-
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 dint 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.'
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; }
-
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 dint 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.'
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 10cout << 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
-
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 dint 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.'
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
-
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
-
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
-
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