hvector.C from MSVS does not work

Hello All,

I wrote a small program which is based on hvector.C in order to store a float vector in a TTree and this tree in a TFile.
If I call the program from root, everything works fine, but unfortunately it does not work if it is called from MSVS.

After calling the program I get the file with the tree which has the branch of integers but not the branch of float vectors.

I assume that I have to include something in order to call it from MSVS.
Looking forward to your feedback.

Regards

Christian

#include <vector>

#include "TFile.h"
#include "TTree.h"

using namespace std;
int main(){
	TFile *f= TFile::Open("test.root", "RECREATE");
	TTree *t_test = new TTree("test tree","test Tree");
	
	int intNumber;
	t_test->Branch("IntNumber",&intNumber);

	vector<float> testFloatVector;
	t_test->Branch("TestFloatVector",&testFloatVector);

	for (int i = 0; i < 200; i++) {
		intNumber = i;
		testFloatVector.clear();
		for (int j = 0; j < 100; ++j) {
			testFloatVector.push_back(i*j);
		}
		t_test->Fill();
	}
	t_test->Write();
	f->Close();
	return 0;
}

Hi,

please do not create your own main(). Simply build a DLL with a dictionary instead that you load into ROOT - using ACLiC (.L MyCode.cxx+) is by far the easiest way. If you do that then your code will just work.

Cheers, Axel.

Hi,

The dictionary for vector is pre-build and can be loaded via:gROOT->ProcessLine("#include <vector>");

Cheers,
Philippe.