From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7021 invoked by alias); 15 Aug 2014 15:54:15 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 7007 invoked by uid 89); 15 Aug 2014 15:54:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f181.google.com Received: from mail-lb0-f181.google.com (HELO mail-lb0-f181.google.com) (209.85.217.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 15 Aug 2014 15:54:11 +0000 Received: by mail-lb0-f181.google.com with SMTP id 10so2053597lbg.40 for ; Fri, 15 Aug 2014 08:54:08 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.152.87.229 with SMTP id bb5mr12886235lab.75.1408118048421; Fri, 15 Aug 2014 08:54:08 -0700 (PDT) Received: by 10.112.94.70 with HTTP; Fri, 15 Aug 2014 08:54:08 -0700 (PDT) In-Reply-To: References: Date: Fri, 15 Aug 2014 15:54:00 -0000 Message-ID: Subject: Re: wifstream From: Jonathan Wakely To: ArbolOne Cc: "gcc >> g++ Mailing List" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00110.txt.bz2 On 15 August 2014 16:49, ArbolOne wrote: > In my Windows 7 this code doesn't work: > std::wstring& getFileName() { > return file_name; > } > myMethod(){ > wchar_t tmp = *getFileName().c_str() ; > std::wifstream infile( tmp ); // <<-- error: invalid conversion > from 'wchar_t' to 'const char*' [-fpermissive] > return infile.good( ); > } > > > It seems to me that std::wifstream does not accept wchar_t as a value > type, but only const char*, contrary to to what is explained in > http://msdn.microsoft.com/en-us/library/3b5w4311.aspx That is describing the MS library, it's not the standard. > Where did I go wrong? or, is this a bug? No, the standard says that basic_fstream always takes narrow character strings to specify the filename, even if the stream itself uses wide characters.