From: David Lowndes on
>To build on Dave's post, I would suggest the newer CA2T and CT2A from ATL
>7+, (instead of the old ATL 3 <X>2<Y> helpers); they have some advantages,

Indeed, they are the ones to use these days. I only mentioned the
others since typing those into the MSDN index get you straight to the
help that references the new ones.

Dave
From: Rayne on
Thank you for all the suggestions.

I'm trying to use the A2T macro for my pcap_loop callback function
"got_packet".

So I have

void got_packet(u_char *cuser, const struct pcap_pkthdr *header, const
u_char *cpacket)
{
_TUCHAR *user, *packet;
user = A2T(cuser);
packet = A2T(cpacket);
...
}

But I have the error messages for the 2 A2T conversions:

error C3861: 'A2T': identifier not found, even with argument-dependent
lookup

Putting my cursor over the A2T shows "#define A2T A2W", so I don't get
why I'm getting the error.

Is there some compiler setting or header files I should include?

Thank you.

Regards,
Rayne
From: Rayne on
Just to add, I've tried CA2T, and I still get the same errors.
From: Rayne on
I'm really confused by this unicode vs multi-byte thing.

Say I'm compiling my program in Unicode (but ultimately, I want a
solution that is independent of the character set used).

1) Will all 'char' be interpreted as wide characters?

2) If I have a simple printf statement, i.e. printf("Hello World\n");
with no character strings, can I just leave it be without using
_tprintf and _T("...")? If the printf statement includes a character
string, then I should use _tprintf and _T("..."), i.e. _tprintf("Hello
%s\n", name); ?

3) If I have a text file (saved in the default format, i.e. without
changing the default character set used) that I want to read into a
buffer, can I still use char instead of TCHAR? Especially if I'm
reading it character by character, i.e. by incrementing the character
pointer?

Thank you.
From: Rayne on
On Feb 9, 10:14 am, Rayne <lancer6...(a)yahoo.com> wrote:
> Just to add, I've tried CA2T, and I still get the same errors.

After including <atlbase.h> and USES_CONVERSION, I get the following
errors for the 2 lines
user = CA2T(cuser);
packet = CA2CT(cpacket);

error C2440: 'type cast': cannot convert from 'const u_char *' to
'ATL::CA2WEX<>'
error C2440: 'type cast': cannot convert from 'u-char *' to
'ATL::CA2WEX<>'