std::ofstream don’t work with short enum in Builder 10.3

  access-violation, c++, c++builder, ofstream, short

If I set "short enum" like true (project->options->c++ compiler), I receive access_violation in return from function where std::ofstream is used.
Example code:

#include <iostream>
#include <fstream>
void __fastcall TForm1::FormCreate(TObject *Sender)
{
        AnsiString textFile = "err.txt";
        std::ofstream out;
        out.open(textFile.c_str());
        out<<textFile.c_str();
        out.close();
}

Somebody know how to set short enum for all project like true and still work with std::ofstream?

ps it’s legacy code and I can’t change size in every emun in project like
enum MyEnum : byte

Source: Windows Questions C++

LEAVE A COMMENT