Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Replacing T2OLE with a ATL 7.0 String conversion classes and Macros

$
0
0
According to MSDN, using T2OLE in a loop may lead to stack overflow, my application uses T2OLE lot of places in the code inside loop for string conversion. I found that usingATL 7.0 string conversion classes and macros has lot of benefits and it solves the stack overflow issue as well,

I tried using the ATL 7.0 as below,

   
_bstr_T example("Hello world");  
for(i=o; i<10000; i++)   
 {      Callsomemethod(i,T2OLE(example)); //This is where I need to replace T2OLE    
 }    

void Callsomemethod(int k, cstring y)   
 {    
  ....    
 }



I found that CT2OLE in ATL 7.0 is equivalent to T2OLE but when I replaced T2OLE with CT2OLE I am getting this issue 

    Error: No suitable user defined conversion from "ATL:CA2W" to Cstring exists 

In the same way I have an other place where it does cstring to _bstr_t and when i replace over there I am getting this 

     Error: No suitable user defined conversion from "ATL:CA2W" to _bstr_t exists 

Can any one help me with this issue?

Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>