How to see constructed code?

Started by
5 comments, last by Prozak 20 years, 5 months ago
Hi there. Using Templates and Macros, and etc, how do I see the code that the compiler constructs, so that i can check some of that code? Thank you.

[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine]
The grass is always greener on the other server.

Advertisement
That depends on the particular compiler/ide you''re using. Some may have an option to spit out things like that into extra files.

You should probably check the documentation that came along with the compiler/ide, or, if it''s a free one, there might be documentation on the site you downloaded the compiler/ide from.
How do I set my laser printer on stun?
For Macros you could try feeding it through a plain pre-processor, most compilers have a pre-process only option.

for templates, i dont know of any way of seeing the C++ code, you should be able to get the compiler to spit out the assembly produced, but i dont think thats what you want.

However you should be able to debug into templates though, unlike macros so you can single step through the template to see what exactly is happening


a good debugger is your best friend..
You can only check out the code if you have the source files and symbols - E.G. not using them as an export from a dll.

In any other scenario looking at the template should be enough - especially if you step through the code using a decent debugger. All what changes in a template is the datatypes used after all.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.
yes, the preprocessor transforms the macros into "final" code, right?

im using VS.NET, is there an option to "output" the final code?

[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine]
The grass is always greener on the other server.

preprocessor will do macros but not templates


in .NET


P (Preprocess to a File)See Also
Compiler Options | Setting Compiler Options
/P
This option preprocesses C and C++ source files and writes the preprocessed output to a file. The file has the same base name as the source file and a .I extension. In the process, all preprocessor directives are carried out, macro expansions are performed, and comments are removed. To preserve comments in the preprocessed output, use the /C option along with /P.

/P adds #line directives to the output, at the beginning and end of each included file and around lines removed by preprocessor directives for conditional compilation. These directives renumber the lines of the preprocessed file. As a result, errors generated during later stages of processing refer to the line numbers of the original source file rather than lines in the preprocessed file. To suppress the generation of #line directives, use /EP as well as /E.

The /P option suppresses compilation. It does not produce an .obj file, even if you use /Fo. You must resubmit the preprocessed file for compilation. /P also suppresses the output files from the /FA, /Fa, and /Fm options.

To send the preprocessed output, with #line directives, or to a file, use the /E option instead of /P.

To send the preprocessed output, without #line directives, to the standard output device, use the /EP option without /P.

To set this compiler option in the Visual Studio development environment

Open the project''s Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
Click the C/C++ folder.
Click the Preprocessor property page.
Modify the Generate Preprocessed File property.
To set this compiler option programmatically

See GeneratePreprocessedFile Property.

Example
The following command line preprocesses ADD.C, preserves comments, adds #line directives, and writes the result to a file, ADD.I:

CL /P /C ADD.C
See Also
thanx, i''ll check that out

[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD]
The grass is always greener on the other server.

This topic is closed to new replies.

Advertisement