std::vector has members right after I declare it

Hello,

I have a problem in which a global vector that I've defined (as an extern) has 1,000,000 members before I even put anything in it. I originally wrote this code as a Win32 application and it worked just fine. I'm now porting it over to Windows Forms and I'm running into this issue. The vector is called "parsed_Commands", and the program is organized as follows:

Datastructs.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef DataStructs_H
#define DataStructs_H

#include "stdafx.h"
#include <string>

struct proc_cmd
{
	std::string type;
	std::string command;

	proc_cmd()
	{
		type = "";
		command = "";
	}
};
#endif 


stdafx.h:
1
2
3
4
5
6
7
#pragma once
#include <Windows.h> 
#include <string>
#include <vector>
#include "DataStructs.h"

extern std::vector<proc_cmd> parsed_Commands;


Main.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "stdafx.h"
#include "Form1.h"
#include "DataStructs.h"

using namespace SpecControl2;
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Security::Permissions;

std::vector<proc_cmd> parsed_Commands;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	parsed_Commands.clear();
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it

	Form1^ Main_Form = gcnew Form1();
	Application::Run(Main_Form);
	return 0;
}


If I set a breakpoint in Main.cpp at the line "Application::EnableVisualStyles();" and then try to expand the parsed_Commands vector in Visual Studio 2012, it tells me that the vector has more than 1,000,000 members and asks if I'm sure I want to expand it. The vector should be completely empty; I just declared it and cleared it. Again, this worked flawlessly in the original Win32 code, even without the clearing. I've also tried defining the extern vector in Datastructs.h and eliminating it from stdafx.h, but this didn't help. Does anyone know what could be going on?
Last edited on
Topic archived. No new replies allowed.