PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > auto decide - char or wchar_t
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
auto decide - char or wchar_t

Réponse
 
LinkBack Outils de la discussion
Vieux 05/02/2008, 06h50   #1
Christopher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut auto decide - char or wchar_t


My book tells me that the compiler will automagically decide whether to
instantiate a basic_iostream with char or wchar_t and I want to do the same
with my class derived from the basic_iostream. I looked at the
implementation of iostream that came with my environment and I found:

#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE)
template class _CRTIMP2_PURE basic_iostream<char, char_traits<char> >;
template class _CRTIMP2_PURE basic_iostream<wchar_t, char_traits<wchar_t> >;

my instinct would tell me to put the same defines for my derived class, but
I don't think that would be very portable, as I believe _DLL_CPPLIB,
_M_CEE_PURE, and _CRTIMP2_PURE to be MS specific or worse even compiler
specific. Is there some portable way to accomplish the same thing?

Even if I use #ifdef #endif blocks I wouldn't know what to put in them for
these defines for other OSes/Compilers.
Any advice?

  Réponse avec citation
Vieux 05/02/2008, 07h28   #2
Jim Langston
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: auto decide - char or wchar_t

Christopher wrote:
> My book tells me that the compiler will automagically decide whether
> to instantiate a basic_iostream with char or wchar_t and I want to do
> the same with my class derived from the basic_iostream. I looked at
> the implementation of iostream that came with my environment and I
> found:
> #if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE)
> template class _CRTIMP2_PURE basic_iostream<char, char_traits<char> >;
> template class _CRTIMP2_PURE basic_iostream<wchar_t,
> char_traits<wchar_t> >;
> my instinct would tell me to put the same defines for my derived
> class, but I don't think that would be very portable, as I believe
> _DLL_CPPLIB, _M_CEE_PURE, and _CRTIMP2_PURE to be MS specific or
> worse even compiler specific. Is there some portable way to
> accomplish the same thing?
> Even if I use #ifdef #endif blocks I wouldn't know what to put in
> them for these defines for other OSes/Compilers.
> Any advice?


I dont think it's the defines that are doing the deciding, but the fact that
there are two templates declared, one for char, one for wchar_t. If you
look at the #else there is probably 2 definitions after it just without
_CRTIMP2_PURE most likely. As it is, you still need to specify which
template to use. Take a look at your declaration of ifstream, for example,
and see how it decides which to instantize.

--
Jim Langston
tazmaster@rocketmail.com


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h09.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10153 seconds with 10 queries