Right well I've got this error and I don't know where to go from here because I can't find out how to get rid of it.
I'm afraid I don't actually know where the error is coming from so I can't just paste a single function or such, but would anyone be so kind as to try and help me find it in this rather large mess I've created?
Exact Error:
error C2075: 'Target of operator new()' : array initialization needs curly braces
File: {install-src-dir}\xmemory0
Line: 606
Column: 1
Project: Data
[LINK - REMOVED]
There are 2 files directly involved and I've had the error since before adding Registry.h but basically the Data namespace is the base of all data handling with my program and also provides a base class (Filed) for everything to derive from, it's an abstract class and hence forces definition of required functions for the child classes.
Have to add some defines so the line numbers are a little off
In file included from Data.h:7:0,
from Data.cpp:1:
Registry.h: In member function ‘bool SB::Registry<T>::save(int, std::string, T)’:
Registry.h:84:6: error: ‘type’ was not declared in this scope
type t = {"NULL", NULL};
Registry.h: In member function ‘bool SB::Registry<T>::load(int, T&)’:
Registry.h:111:3: error: expected ‘;’ before ‘}’ token
return false
}
In file included from Data.cpp:1:0:
Data.h: In function ‘std::string SB::Data::writeArrayToString(std::string, T*)’:
Data.h:187:27: error: expected initializer before ‘i’
for(bool b=false, uint i=0; i+2<types.size(), !b; i+=2){
Data.h:220:11: warning: deleting ‘void*’ is undefined [enabled by default]
delete hWnd;
Strange how come none of those appear on my compiler log, I can fix most of them quite easily and I'll let you know when I've updated the files...
Not sure why 'uint' isn't recognised as a type though?!
Every name introduced in the same declaration (regardless if it's in a for loop or not) must have the same type, or be modified from the same type by applying pointer-to, reference-to, array-of, and function-returning declarators, or a combination of those.
You can write int n, m, *p, arr[10]; for example (although it would look silly in the init clause of for loop), but you can't declare an int and a bool in the same declaration.
Okay I've fixed the errors which you've pointed out (thanks) and the files under that link have been updated, but I'm still getting only that one error about the new operator needing curly braces:
error C2075: 'Target of operator new()' : array initialization needs curly braces
File: {install-src-dir}\xmemory0
Line: 606
Column: 1
Project: Data
The problem is that you are lying, that is not the code that you are compiling.
Nah. The code he's using will cause the error, but it looks like he isn't posting the full text of the error. He's posting what it would show in the "Error List" in VS, which is an abbreviated version of the actual compiler output. If he checked the actual output (which is typically a tab in the same window as the "Error List") he would get something a bit more informative.
The following:
1 2 3 4 5 6 7 8 9
#include <vector>
int main()
{
std::vector<int[2]> v;
int n[2];
v.push_back(n);
}
results in:
1>------ Build started: Project: Junk, Configuration: Release Win32 ------
1> main.cpp
1>...\xmemory0(615): error C3074: an array can only be initialized with an initializer-list
1> ...\xmemory0(614) : while compiling class template member function 'void std::allocator<_Ty>::construct(_Ty (*),const _Ty (&))'
1> with
1> [
1> _Ty=int [2]
1> ]
1> ...\xmemory0(752) : see reference to function template instantiation 'void std::allocator<_Ty>::construct(_Ty (*),const _Ty (&))' being compiled
1> with
1> [
1> _Ty=int [2]
1> ]
1> ...\type_traits(580) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
1> with
1> [
1> _Ty=int [2]
1> ]
1> ...\vector(650) : see reference to class template instantiation 'std::is_empty<_Alloc>' being compiled
1> with
1> [
1> _Alloc=std::allocator<int [2]>
1> ]
1> main.cpp(5) : see reference to class template instantiation 'std::vector<int [2],std::allocator<_Ty>>' being compiled
1> with
1> [
1> _Ty=int [2]
1> ]