# How to SetBit(TFile::k630forwardCompatibility)

**URL:** <https://root-forum.cern.ch/t/how-to-setbit-tfile-k630forwardcompatibility/64315>\
**Category:** Newbie\
**Tags:** root\
**Created:** [October 15, 2025, 3:14am UTC](https://root-forum.cern.ch/t/how-to-setbit-tfile-k630forwardcompatibility/64315 "2025-10-15T03:14:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [October 15, 2025, 3:14am UTC](https://root-forum.cern.ch/t/how-to-setbit-tfile-k630forwardcompatibility/64315/1 "2025-10-15T03:14:57Z")

</div>

* * *

_Dear experts_

I want to set the compatibility for a ROOT file, and I’m suggested to do it by `TFile::SetBit(TFile::k630forwardCompatibility)`, but when I try to change it, I found I couldn’t:

```auto
root [0] TFile* f = TFile::Open("SimDetectorResponse/parameters/RECBE_response/response_RECBE002ch24_20241121.root", "Update")
(TFile *) 0x43b6870
root [1] f->TestBit(TFile::k630forwardCompatibility)
(bool) false
root [2] f->SetBit(TFile::k630forwardCompatibility)
root [3] f->TestBit(TFile::k630forwardCompatibility)
(bool) true
root [4] f->Write()
(int) 0
root [5] f->TestBit(TFile::k630forwardCompatibility)
(bool) true
root [6] f->Close()
root [7] delete f;
root [8] TFile* f = TFile::Open("SimDetectorResponse/parameters/RECBE_response/response_RECBE002ch24_20241121.root", "Update")
(TFile *) 0x43b6870
root [9] f->TestBit(TFile::k630forwardCompatibility)
(bool) false

```

* * *

How can I change it?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [October 15, 2025, 5:56am UTC](https://root-forum.cern.ch/t/how-to-setbit-tfile-k630forwardcompatibility/64315/2 "2025-10-15T05:56:13Z")

</div>

Maybe @pcanal can help

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 15, 2025, 11:52am UTC](https://root-forum.cern.ch/t/how-to-setbit-tfile-k630forwardcompatibility/64315/3 "2025-10-15T11:52:20Z")

</div>

I think this was fixed some time ago, see the versions that include the fix here:

> <https://github.com/root-project/root/issues/16189>
>
> \### Check duplicate issues.
> 
> \- \[X\] Checked for duplicates
> 
> \### Description
> 
> When… setting \`TFile.v630forwardCompatibility\` to true in \`/etc/root/system.rootrc\`, there is still confusing behavior and new files can be written without compability. In particular, \*new\* files are not opened in compatibility mode (largely limiting the usefulness of the configuration flag).
> 
> \### Reproducer
> 
> \`\`\`
> gEnv-\>GetValue("TFile.v630forwardCompatibility", 0)
> 
> TFile file1 = TFile("file1.root","CREATE")
> file1.TestBit(TFile::k630forwardCompatibility)
> file1.Close()
> 
> TFile file2 = TFile("file1.root","READ")
> file2.TestBit(TFile::k630forwardCompatibility)
> file2.Close()
> 
> TFile\* file3 = TFile::Open("file3.root","CREATE")
> file3-\>TestBit(TFile::k630forwardCompatibility)
> file3-\>Close()
> 
> TFile\* file4 = TFile::Open("file3.root","READ")
> file4-\>TestBit(TFile::k630forwardCompatibility)
> file4-\>Close()
> \`\`\`
> produces
> \`\`\`
> $ root -l 
> root \[0\] gEnv-\>GetValue("TFile.v630forwardCompatibility", 0)
> (int) 1
> root \[1\] 
> root \[1\] TFile file1 = TFile("file1.root","CREATE")
> (TFile &) Name: file1.root Title: 
> root \[2\] file1.TestBit(TFile::k630forwardCompatibility)
> (bool) false
> root \[3\] file1.Close()
> root \[4\] 
> root \[4\] TFile file2 = TFile("file1.root","READ")
> (TFile &) Name: file1.root Title: 
> root \[5\] file2.TestBit(TFile::k630forwardCompatibility)
> (bool) true
> root \[6\] file2.Close()
> root \[7\] 
> root \[7\] TFile\* file3 = TFile::Open("file3.root","CREATE")
> (TFile \*) 0x5650bd7edba0
> root \[8\] file3-\>TestBit(TFile::k630forwardCompatibility)
> (bool) false
> root \[9\] file3-\>Close()
> root \[10\] 
> root \[10\] TFile\* file4 = TFile::Open("file3.root","READ")
> (TFile \*) 0x5650bd584570
> root \[11\] file4-\>TestBit(TFile::k630forwardCompatibility)
> (bool) true
> root \[12\] file4-\>Close()
> \`\`\`
> 
> \### ROOT version
> 
> \`\`\`
> ------------------------------------------------------------------
> | Welcome to ROOT 6.30/02 https://root.cern |
> | (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
> | Built for linuxx8664gcc on Aug 02 2024, 15:34:40 |
> | From heads/master@tags/v6-30-02 |
> | With g++ (Debian 12.2.0-14) 12.2.0 |
> | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
> ------------------------------------------------------------------
> \`\`\`
> 
> \### Installation method
> 
> Spack
> 
> \### Operating system
> 
> Linux, debian
> 
> \### Additional context
> 
> Ref. #15006 .

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [October 15, 2025, 3:48pm UTC](https://root-forum.cern.ch/t/how-to-setbit-tfile-k630forwardcompatibility/64315/4 "2025-10-15T15:48:22Z")

</div>

The meaning of the flag is to change the way object are stored in the file. It can not change the way object are already stored.

So you need to set the flag when creating the file **before** writing any objects in it.

In addition this bit is not a persistent property of the file. i.e. you need to set it whenever you want to update it (alternative you can use .rootrc setting to do so automatically for all files).

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [October 18, 2025, 12:14pm UTC](https://root-forum.cern.ch/t/how-to-setbit-tfile-k630forwardcompatibility/64315/5 "2025-10-18T12:14:43Z")

</div>

This means I need to `SetBit` right after I create the TFile?

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [October 19, 2025, 2:47am UTC](https://root-forum.cern.ch/t/how-to-setbit-tfile-k630forwardcompatibility/64315/6 "2025-10-19T02:47:40Z")

</div>

yes, you are correct.
