How to get the assembly equivalent of a CPP file that has only templates

I have a C ++ file that only has the template methods of the template class. I tried to compile this with the -S option.

It creates a .s file, but there is no build code in it - for example:

.section        ".text",#alloc,#execinstr

.file   "eac_slist.C"
.xstabs ".stab.index","V=9.0;DBG_GEN=5.0.8;dm;cd;backend;ptf;ptx;ptk;ptr/vobs/eam;s;;P;R=5.8<<Sun C++ 5.8 2005/10/13 (ccfe)>>;A=2",60,0,0,0
.xstabs ".stab.index","/vobs/ossrc_3pp/freeware/studio11/SUNWspro/prod/bin/CC -I. -S  -xs  eac_slist.C",52,0,0,0

Can anyone help with this?

+3
source share
3 answers

A template is only converted to code when instantiating this template. You will not get any asm for the template unless you create one.

However, you can ask the instance instance to explicate the instance instance:

template class TemplatedClass<char>;

​​ c , asm, char .


, : , ?

, , , , .

, .

  • ,
  • , (1)
  • , .
  • - .

, (.. , ).

-g gcc , , , .

, .

, , .

+7

. , , , .

, . .

+2

Unless you actually use boilerplate code, the compiler is not required to create anything.

+1
source

Source: https://habr.com/ru/post/1775607/


All Articles