2

I am porting existing VC12 compiler compatible code to VC14 (visual studio 2015) and I am facing code break problem.

Sample program to reproduce issue:

#include "iostream"
using namespace std;
#define mybuffer(param)       ((param)->_flag & (_IOMYBUF))

int main()
{
    mybuffer(stderr); // I don't understand what is the purpose of this line.
                      // So, facing issue in replacing this code statement.
    return 0;
}

On visual studio 2013: above program works absolutely fine.

On visual studio 2015: above program gives compilation error.

Error C2039 '_flag': is not a member of '_iobuf'

Error C2065 '_IOMYBUF': undeclared identifier

Analysis:

In VS2013, wchar.h has following:

struct _iobuf {
    char *_ptr;
    int   _cnt;
    char *_base;
    int   _flag;
    int   _file;
    int   _charbuf;
    int   _bufsiz;
    char *_tmpfname;
    };
typedef struct _iobuf FILE;

Where as in VS2015, in file: corecrt_wstdio.h

#ifndef _FILE_DEFINED
#define _FILE_DEFINED
typedef struct _iobuf
{
    void* _Placeholder;
} FILE;
#endif

Can you please help me in suggesting a fix for above error?

Jatin
  • 1,857
  • 4
  • 24
  • 37
  • See https://connect.microsoft.com/VisualStudio/feedback/details/1419290/file-is-not-a-member-of-iobuf-bug. Basically the old code was poking into undocumented parts of an implementation detail. If you could say what the original code was trying to actually achieve, we may be able to help find a way to do that that is allowed. – Mike Vine May 17 '17 at 10:27
  • 5
    The connect.microsoft.com link is invalid :( `Microsoft Connect Has Been Retired` – Bernhard Döbler Apr 21 '18 at 12:22
  • were you able to fix the issue. – Priyank Bolia Jun 18 '20 at 07:28

0 Answers0