Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. VC6 problem: locale loc(locale::classic(), new myfac)

VC6 problem: locale loc(locale::classic(), new myfac)

Scheduled Pinned Locked Moved ATL / WTL / STL
c++testingbeta-testinghelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John R Shaw
    wrote on last edited by
    #1

    Yes I am still supporting VC6 in this project and it has to be cross platform. Buried in the VC6 MSDN Library under “locale::facet” is the line “locale loc(locale::classic(), new myfac);”. Which is correct for latter versions of the MS STL, but there is no locale constructor that takes a locale and a facet defined in the VC6 STL version of locale. My unsatisfactory workaround is:

    #ifdef _ADDFAC // Dinkumware macro
    std::locale myLoc = std::_ADDFAC(std::locale::classic(), new my_codecvt);
    #else
    std::locale myLoc = std::locale(std::locale::classic(), new my_codecvt);
    #endif

    Do you have a better one?

    INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

    S 1 Reply Last reply
    0
    • J John R Shaw

      Yes I am still supporting VC6 in this project and it has to be cross platform. Buried in the VC6 MSDN Library under “locale::facet” is the line “locale loc(locale::classic(), new myfac);”. Which is correct for latter versions of the MS STL, but there is no locale constructor that takes a locale and a facet defined in the VC6 STL version of locale. My unsatisfactory workaround is:

      #ifdef _ADDFAC // Dinkumware macro
      std::locale myLoc = std::_ADDFAC(std::locale::classic(), new my_codecvt);
      #else
      std::locale myLoc = std::locale(std::locale::classic(), new my_codecvt);
      #endif

      Do you have a better one?

      INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      I'm sure this is teaching grandma to suck eggs, but the only thing I'd suggest is to encapsulate that in another function, so you only need to do it once, i.e:

      template<class Facet>
      std::locale AddFacet(std::locale const& l, const Facet* f)
      {
      #ifdef _ADDFAC // Dinkumware macro
      return std::_ADDFAC(std::locale::classic(), new my_codecvt);
      #else
      return std::locale(std::locale::classic(), new my_codecvt);
      #endif
      }

      Alternatively, use this:

      #ifndef _ADDFAC // Dinkumware macro
      #define _ADDFAC (std::locale)
      #endif

      and use _ADDFAC for all platforms.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups