Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Upgrading to C++Builder 12.2: Tip #3, Massive Files with iostreams

Splash image for tips and tricks upgrading to C++Builder 122 how to use massive files with iostreams

Screenshot Radically Different Why C++Builder 122 Matters webinarWelcome to a series of tips and tricks for taking advantage of the new Windows 64-bit Modern toolchain in C++Builder / RAD Studio 12.2! This builds on a webinar we did sharing a bunch of useful information on why and how the new C++Builder matters to you, where this was the very end (so go watch the start!)

Tip #3: Massive Files with iostreams

The old C++ Win64 STL had a maximum size of 4GB for files, even compiling as 64-bit. That meant if you used iostreams to handle a large file, you were out of luck. (Isn’t it good we replaced our STL?)

In 12.2, the new Win64 RTL keeps this by default (in 12.2) but can support massive files!

Just define: _FILE_OFFSET_BITS=64 in the compiler options.

Or, on the command line: -D_FILE_OFFSET_BITS=64

We might enable this by default in the next release.

Bonus tip: check out the RTL TEncoding class. This, with stream support, make it much easier to handle text encodings than C++’s default classes to, plus of course already support 64-bit file sizes, and you get great performance with TBufferedFileStream. But if you want to use the STL, with the new C++Builder you’re ok there too!

Exit mobile version