Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

wchar_t in Inventor C++ code

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
oransen
571 Views, 3 Replies

wchar_t in Inventor C++ code

In the C++ Inventor programming examples I see a lot of uses of the T string macro. I imagine this is to handle both wchar_t and char strings. But with recent OSs can I safely always use wchar_t? How many people are using Inventor in a system which is not default UNICODE?

 

I know UNICODE and wchar_t are not identical, but you get the gist of my question. I want to always use wchar_t without having to use those untidy _T macros.

 

3 REPLIES 3
Message 2 of 4
adam.nagy
in reply to: oransen

Hi,

 

My understanding is that the use of those macros is just to enable you to compile your project to be Unicode enabled or not. E.g. when long ago AutoCAD was adding Unicode support and you still wanted to compile your project for an older version that did not support Unicode then using these macros it was a matter of compiler setting switch to compile for one version then to another version.

C++ Project Settings >> "Configuration Properties" >> "General" >> "Character Set" = "Use Unicode Character Set"

 

If your project is always built with Unicode support switched on then I don't think you'd need those _T macros.

It's your decision. 🙂

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 4
oransen
in reply to: adam.nagy

So, I'll just use wchar_t throughout, with appropriate COM wrappers when neccessary?

 

 

Message 4 of 4
adam.nagy
in reply to: oransen

Hi,

 

Yes, I think that should be fine. You of course have to check what type of string a given function is requesting. In case of calling Inventor API functions the strings are required as BSTR (sometimes wrapped in a VARIANT) which you can get in multiple ways and I think all of them can create it from wchar_t: SysAllocString, CComBSTR, _bstr_t

http://stackoverflow.com/questions/3323177/c-convert-wchar-t-to-bstr

 

Cheers,



Adam Nagy
Autodesk Platform Services

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report