Problem with #include and using namespace


ROOT Version: 6.16
Platform: VS2017(15.9.13)
Compiler: Not Provided


Hi,
I’ve just installed ROOT with the corresponding VS2017, C++ Desktop Dev, as well as Windows10 SDK.
Everything within ROOT (histogram, canvas, function, etc) seems working fine, but after I
#include or using namespace, ROOT simply stops working when I try to use anything from those included.

nuts

An example here is that I try to create an object of ofstream which stops ROOT from working, despite ROOT recognizing the type ofstream.

How can I fix this problem? Or is there any alternative ways that I can read from a file (raw data)?

@bellenot can you confirm this? If so I’ll happily debug this with you tomorrow!

1 Like

You’re right, it doesn’t work. We’ll debug this and let you know. Thanks @Axel for your offer :wink:

1 Like

FYI, a related Jira Issue has been created

So I was wrong, this works with ROOT master and Visual Studio 2019:

C:\Users\bellenot\build\debug>root -l
root [0] #include <iostream>
root [1] #include <fstream>
root [2] #include <string>
root [3] using namespace std;
root [4] string filename = "Test.b";
root [5] ofstream ostrm(filename, std::ios::binary);
root [6] double d = 3.14;
root [7] ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // binary output
root [8] ostrm << 123 << "abc" << '\n';                      // text output
root [9] .q

C:\Users\bellenot\build\debug>root -l
root [0] #include <iostream>
root [1] #include <fstream>
root [2] #include <string>
root [3] using namespace std;
root [4] string filename = "Test.b";
root [5] ifstream istrm(filename, ios::binary);
root [6] double d;
root [7] istrm.read(reinterpret_cast<char*>(&d), sizeof d);
root [8] int n;
root [9] string s;
root [10] istrm >> n >> s;
root [11] cout << " read back: " << d << " " << n << " " << s << '\n';
read back: 3.14 123 abc
root [12] .q
C:\Users\bellenot\build\debug>

I’ve tried VS2019 with C++ Desktop Dev and Windows 10 SDK, the same issue reappears.

Btw, there is a “master” version?

This is the master branch of git (https://github.com/root-project/root), built from source (https://root.cern.ch/building-root)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.