Jump to page: 1 2
Thread overview
Is there a way to "see" source code generated by templates after a compile?
Jul 17, 2016
WhatMeWorry
Jul 17, 2016
rikki cattermole
Jul 17, 2016
Stefan Koch
Jul 17, 2016
WhatMeWorry
Jul 17, 2016
zabruk70
Jul 17, 2016
Stefan Koch
Jul 18, 2016
Nicholas Wilson
Jul 18, 2016
Stefan Koch
Jul 18, 2016
Stefan Koch
Jul 18, 2016
lobo
Jul 18, 2016
WhatMeWorry
Jul 19, 2016
WhatMeWorry
Jul 20, 2016
ZombineDev
July 17, 2016

I don't suppose there's a way to "see" source code generated by templates after a compile but before execution?  Or does the compiler generate it to a lower level on the fly; thus losing the source code?

I'm assuming no because if there were a way, I'd of come across it by now :)


Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?



July 17, 2016
On 17/07/2016 5:57 PM, WhatMeWorry wrote:
>
>
> I don't suppose there's a way to "see" source code generated by
> templates after a compile but before execution?  Or does the compiler
> generate it to a lower level on the fly; thus losing the source code?
>
> I'm assuming no because if there were a way, I'd of come across it by
> now :)

There isn't and it has been asked for (I for one want it).

> Now that I think about, was there even a way to look at c/c++ code after
> the pre-processor step?

Yup. But that is done by an external tool most of the time.


July 17, 2016
On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:
>
>
> I don't suppose there's a way to "see" source code generated by templates after a compile but before execution?  Or does the compiler generate it to a lower level on the fly; thus losing the source code?
>
> I'm assuming no because if there were a way, I'd of come across it by now :)
>
>
> Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?

If you do use mixins I can craft you a patch.
If you want to see template expansions you have to wait a little longer.
July 17, 2016
On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:
> On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:
>>
>>
>> I don't suppose there's a way to "see" source code generated by templates after a compile but before execution?  Or does the compiler generate it to a lower level on the fly; thus losing the source code?
>>
>> I'm assuming no because if there were a way, I'd of come across it by now :)
>>
>>
>> Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?
>
> If you do use mixins I can craft you a patch.
> If you want to see template expansions you have to wait a little longer.

Wonderful! Nope, I can wait. I don't want to do anything that would slow you down. This will make learning and debugging code generation so much easier.
July 17, 2016
On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:
> If you want to see template expansions you have to wait a little longer.

Wow! Is this really possible?! So long time several peoples asked this...
July 17, 2016
On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote:
> On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:
>> If you want to see template expansions you have to wait a little longer.
>
> Wow! Is this really possible?! So long time several peoples asked this...

I am reasonably sure that I can do it :)

However don't expect anything pretty.
The indentation will be long gone ...
July 18, 2016
On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:
>
[snip]

>
> Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?

Does this do what you want?

cl.exe /E
gcc -E
clang -E
clang-cl /E




July 18, 2016
On Sunday, 17 July 2016 at 16:30:38 UTC, Stefan Koch wrote:
> On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote:
>> On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:
>>> If you want to see template expansions you have to wait a little longer.
>>
>> Wow! Is this really possible?! So long time several peoples asked this...
>
> I am reasonably sure that I can do it :)
>
> However don't expect anything pretty.
> The indentation will be long gone ...

Just pipe it through dformat should do a good enough job.
July 18, 2016
On Monday, 18 July 2016 at 07:37:27 UTC, lobo wrote:
> On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote:
>>
> [snip]
>
>>
>> Now that I think about, was there even a way to look at c/c++ code after the pre-processor step?
>
> Does this do what you want?
>
> cl.exe /E
> gcc -E
> clang -E
> clang-cl /E

i appreciate the reply but you're about 20 years too late :)  Thankfully, my c/c++ days are long gone.  Long live D.
July 18, 2016
On Sunday, 17 July 2016 at 16:30:38 UTC, Stefan Koch wrote:
> On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote:
>> On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote:
>>> If you want to see template expansions you have to wait a little longer.
>>
>> Wow! Is this really possible?! So long time several peoples asked this...
>
> I am reasonably sure that I can do it :)


I did it for function templates just now.
It will the instantiated bodys to std-out.

« First   ‹ Prev
1 2